Advance Innovation Centre
  • AIC Knowledge @ EEC for All
  • 😎Logical Thinking
    • Karel Robot
    • Code to Flowchart
    • Play with Docker
    • CNX Software
  • MCU & Interfacing with Infineon PSOC™
    • Basic MCU Interfacing
      • Introduction to CY8CKIT-062S2-43012 Pioneer Kit
      • Development Environment Preparation
      • PSoC™ 6S2 Peripherals Interfacing (GPIO)
        • Hello World and LED Blinking
        • GPIO Principles
        • PSoC™ 6S2 GPIO-HAL LED Blink Lab
        • PSoC™ 6S2 GPIO-PDL LED Blink Lab
        • Button "Bounce" Principles
          • Push/Pull Button to Turn ON/OFF LED via HAL
          • Push/Pull Button to Turn ON/OFF LED via PDL
          • GPIO Button Interrupt via HAL
          • GPIO Button Interrupt via PDL
        • GPIO variables & functions
      • PSoC™ 6S2 Peripherals Interfacing (ADC, PWM)
        • PSoC™ 6S2 SAR ADC
          • ADC Principles
          • PSoC™ 6S2 with ADC Labs
            • Reading potentiometer sensor value via an ADC HAL
            • Reading potentiometer sensor value via an ADC PDL
        • PSoC™ 6S2 PWM & TCPWM
          • PWM Principles
          • PSoC™ 6S2 for PMW Function Labs
            • LED Brightness using PWM via HAL
            • LED Brightness using PWM via PDL
    • Sensor Interfacing and HMI
      • OLED Display
        • OLED Display Principles
        • Calling BDH’s OLED functions
        • Display ADC via Potentiometer on OLED
      • BDH Shell
        • Shell Principles
        • LED Blinking and CAPSENSE via BDH Shell
        • Adding "History" command
        • Adding "Reboot" command
        • CAPSENSE Button and Slider
          • CAPSENSE Button and Slider with Capsense Tuner
          • CAPSENSE Button and Slider using FreeRTOS
    • Serial Communication & Visualization
      • UART, I2C, SPI Communication via Infineon PSoC™6
      • BMX160 Sensor Communication via Infineon PSoC™6
        • Reading ADC via HAL with Potentiometer and Displaying GUI on Serial Studio
        • Reading XENSIV-DPS-3XX Pressure Sensor and Displaying GUI on Serial Studio
        • Motion Sensors GUI Integration via Serial Studio
    • IoT Connectivity & Data Analytics via Node-Red
      • Node-Red Installation
      • Setting MQTTS to MQTT Broker
      • Sending PSoC6’s sensor to MQTT (node-red)
    • Edge AI on PSoC™
      • Machine Learning on PSoC™6 via Edge-Impulse
    • Infineon PSoC™ Troubleshooting
  • IoT Development with Infineon PSOC™ & BDH Platform
    • PSoC™ IoT Development Kit
      • Introduction to CY8CKIT-062S2-43012 Pioneer Kit
      • Development Environment Preparation
        • Hello World and LED Blinking
    • IoT Connectivity
      • Node-Red Installation
      • Controlling PSoC™ LED using MQTT
      • Setting MQTTS to MQTT Broker
      • Sending PSoC6’s sensor to MQTT (node-red)
    • BDH IoT Connectivity
    • WireLinX™ IoT PLC
    • BDH X-Brain Data Analytics
      • PSoC6 Data Collection to CSV log file
    • Data Visualization
      • สร้าง Dashboard ด้วย Looker Studio
  • 🖥️Operation Systems
    • Prerequisites
      • Guideline from Ubuntu
        • Ubuntu and VSCode on WSL2
      • ติดตั้ง WSL 2
      • Run Ubuntu on VirtualBox7
    • Zero to Linux Hero
      • Computer OS Architecture
      • Anatomy of Linux System
        • UNIX/Linux History
        • UNIX/Linux Evolution
        • GNU Project
        • Linux OS Architecture
        • Command Line Interface (CLI)
          • Basic Commands
          • 😎Level up your Linux Shell
          • File & Dir. Commands
          • Searching Commands
          • 😎ChatGPT-based Terminal
          • SysAdmin Commands
          • Network Commands
          • Hacker Commands
        • Busybox
        • Shell Script
          • Awk Script
          • Bash Shell Script
            • Bash Snippets
            • Bash Useful Examples
      • Anatomy of Linux Kernel
        • Linux Kernel Principles
        • Linux Environment for Developer
      • Anatomy of Embedded Linux
        • Embedded Linux
        • Host & Target
        • Cross Toolchains
        • Bootloader
        • Building Embedded Linux
    • Linux OS Dev. Engineer
      • Process Management
        • Process Basic
        • Process State
        • Basic Process Mgmt. Commands
        • Advance Process Mgmt. Commands
        • Process API Programming
      • IPC
        • IPC Anatomy
        • Signal Programming
        • Pipe Programming
        • FIFO Programming
        • Msg. Queue Programming
          • System V
        • Share Memory Programming
          • System V
        • Socket Programming
      • POSIX Threads
        • Multi-tasking Basic
        • POSIX Thread Anatomy
        • Threading Programming
      • Applied IPC
        • Remote Commander
        • Multi-Remote Commanders
      • Process Synchronization
        • Mutex Programming
        • Semaphore Programming
      • Applied IPC with Semaphore
  • ⌚Embedded Systems Development
    • Introduction to ESD
      • Why's ESD?
      • What it use for?
      • How it works?
    • Enbedded System Development via PSoC6
      • Basic MCU Interfacing
        • Introduction to CY8CKIT-062S2-43012 Pioneer Kit
        • Development Environment Preparation
        • PSoC™ 6S2 Peripherals Interfacing (GPIO)
          • Hello World and LED Blinking
          • GPIO Principles
          • PSoC™ 6S2 GPIO-HAL LED Blink Lab
          • PSoC™ 6S2 GPIO-PDL LED Blink Lab
          • Button "Bounce" Principles
            • Push/Pull Button to Turn ON/OFF LED via HAL
            • Push/Pull Button to Turn ON/OFF LED via PDL
            • GPIO Button Interrupt via HAL
            • GPIO Button Interrupt via PDL
          • GPIO variables & functions
        • PSoC™ 6S2 Peripherals Interfacing (ADC, PWM)
          • PSoC™ 6S2 SAR ADC
            • ADC Principles
            • PSoC™ 6S2 with ADC Labs
              • Reading potentiometer sensor value via an ADC HAL
              • Reading potentiometer sensor value via an ADC PDL
          • PSoC™ 6S2 PWM & TCPWM
            • PWM Principles
            • PSoC™ 6S2 for PMW Function Labs
              • LED Brightness using PWM via HAL
              • LED Brightness using PWM via PDL
      • Sensor Interfacing and HMI
        • OLED Display
          • OLED Display Principles
          • Calling BDH’s OLED functions
          • Display ADC via Potentiometer on OLED
        • BDH Shell
          • Shell Principles
          • LED Blinking and CAPSENSE via BDH Shell
          • Adding "History" command
          • Adding "Reboot" command
          • CAPSENSE Button and Slider
            • CAPSENSE Button and Slider with Capsense Tuner
            • CAPSENSE Button and Slider using FreeRTOS
      • Serial Communication & Visualization
        • UART, I2C, SPI Communication via Infineon PSoC™6
        • BMX160 Sensor Communication via Infineon PSoC™6
          • Reading ADC via HAL with Potentiometer and Displaying GUI on Serial Studio
          • Reading XENSIV-DPS-3XX Pressure Sensor and Displaying GUI on Serial Studio
          • Motion Sensors GUI Integration via Serial Studio
    • Edge Computing and IoT Connectivity
    • Cloud-Based Data Analytics and Digital Twin
    • Edge Vision AI
    • Resources
      • Basic Hardware and Firmware
        • Environment Preparation
          • การติดตั้งโปรแกรม Arduino IDE
            • ตัวอย่างการเริ่มต้นใช้งาน Arduino IDE
          • การติดตั้งโปรแกรมสำหรับใช้งานเครื่องมือวัด NI MyDAQ
            • ตัวอย่างการตั้งค่าใช้ Digital Multimeter -NI ELVISmx
            • ตัวอย่างการตั้งค่าใช้ Oscilloscope-NI ELVISmx
          • ติดตั้งโปรแกรม KingstVIS
        • Basic measurement
          • Basic Digital and Analog I/O
            • LAB: Basic Digital Input/Output
            • LAB: Basic Analog Input/Output
          • Waveform
            • LAB: Oscilloscope
            • LAB: Oscilloscope and Function Generator
            • LAB: Pulse Width Modulation (PWM)
              • Homework
        • Interfacing and Communication
          • LAB: UART, RS485, RS232 Protocol
          • LAB: I2C Protocol
            • HOMEWORK
          • LAB: SPI Protocol
      • IoT Connectivity
        • Example: IoT with MQTT on Node-red
        • Data logger
        • LAB: Data Visualization
  • 🛠️C/C++ for Embedded Programming
    • Development Environment Preparation
      • ติดตั้ง WSL 2
      • ติดตั้ง Ubuntu environment
      • ติดตั้งโปรแกรม Visual Studio Code
      • การเชื่อมต่อ Virtual studio code เข้ากับ WSL
      • ติดตั้ง docker on WSL
    • Principle C/C++ Programming
      • Get started with C++
      • Makefile
        • Makefile Examples
      • Compiling and running
        • How to create a program that you can enter inputs.
          • Lab 1 Exercise
      • Arguments
        • Command line arguments in C and C++
      • signed and unsigned data types
      • Variable and Operator
      • If and If else
      • Loop, Infinite loop, and flag
        • Loop and Flag exercise
      • Array
        • Get to know with arrays
        • Implement example
      • Vector
    • Object Oriented Programming (OOP) in C++
      • Class and Object
      • Encapsulation and Abstraction
      • Polymorphism and Inheritance
    • C/C++ Preprocessing
      • Macro
        • Quiz Macro
      • File Inclusion
      • Conditional Compilation
      • Pragma directive
        • Quiz Pragma
    • String in C++
      • Concatenation
      • Split
    • Type conversions for C/C++
      • Conversion using Cast operator
    • Error handling
    • Data logger
      • การสร้างไฟล์และเขียนไฟล์
      • การอ่านไฟล์
      • การเก็บข้อมูลกับTime stamp
    • High performance programing
      • Multi-task and Multi-thread
        • Multi-threading example
      • Mutex
      • Queue
      • OpenCV
    • C/C++ Techniques
      • Makefile in action
      • Object Oriented Programming (OOP) in C++
        • Class and Object
        • Encapsulation and Abstraction
        • Polymorphism and Inheritance
      • C/C++ Preprocessing
        • Macro
          • Quiz Macro
        • File Inclusion
        • Conditional Compilation
        • Pragma directive
          • Quiz Pragma
      • Binary, Octal and Hexadecimal Numbers
      • Array and properties of an array
        • Get to know with arrays
        • Implement example
      • What's next?
  • 🤖Artificial Intelligence (AI)
    • VAMStack Design House, BUU
    • Data Analytics
      • Data cleansing
      • Data analytics
      • Data analytic exercise
    • Machine Learning
      • Neural Network Layers
      • Machine learning type
      • Dataset
      • Using Edge Impulse for AI Model
    • Basic Image Processing
      • Computer Vision using Python Language
        • Installation
        • Computer Vision Basics
          • Pixel and Color
          • Draw image
          • Basic Image processing
          • Morphology Transformations
          • Gaussian blur
          • Simple Thresholding
          • Contour
          • Canny edge detection
        • Case Study
          • Coin counting
          • Color detection & tracking
        • VAM_CV SDK
  • ⚙️FPGA Design and Development
    • Verilog HDL via Vivado IDE
      • LAB1: Setting Environment and Create Project
        • Create Vivado Project
      • LAB2: Hardware Description Language Work Flow
        • Simulation code
      • LAB3: Design HDL Project
        • Top Level Design
        • Top-level Simulation
      • LAB4: Asynchronous VS Synchronous Circuit
        • Simulation Synchronous counter
    • C/C++ Programming on Ultra96v2 FPGA Board
      • Application C/C++ on Ultra96v2 Part 1
        • Design Overview
        • Step 1 - Burn the image to SD card
        • Step 2 - Bring up Ultra96v2
        • Step 3 - Installing the Vitis-AI runtime packages
      • Application C/C++ on Ultra96v2 Part 2
        • STEP 1 : Setting auto boot Wifi
        • STEP 2 : How to working on Embedded
        • STEP 3 : How to run the test code
  • 🤖Robotics
    • Dobot Magician
      • Instruction of Dobot
      • Software Download
      • Basically of Program
        • Teaching and Playback
        • Write and Draw
        • LaserEngraving
        • 3D Printer
    • Robotino
      • Software Download
        • Robotino View
        • Robotino SIM
      • Charging
      • Connecting
      • Follow Line example
        • Basic block in Follow Line
    • RaspBlock
      • Get Started with Raspblock
  • 🚩Special Topics
    • Node-Red
      • Set up Raspberry Pi
      • Install node red in Raspberry Pi
      • Get started with Node Red
        • Open node-red
        • Turn off node red
        • Install Dashboard on Node-red
        • Use node red to show message
        • Using Ultrasonic sensor with node-red
    • IoT Cloud
      • Overview
        • How do they work?
          • Basic Knowlege
      • Installations
        • Install Docker
        • Install Mosquitto Broker
        • Install InfluxDB
        • Install Telegraf
        • Install Grafana
      • Get Sensor Value and Send to MQTT
        • Connect ESP3266 to sensor
        • Connect ESP3266 to MQTT
      • Integration
    • Senses IoT
      • SENSES IoT Platform
      • LAB8: MCU send data to IoT platform
    • CrowPi Dev Kit
      • Raspberry Pi with CrowPi
      • Remote to Raspberry Pi
      • Cross-Compile
        • Lab 1: Programming and cross complier
      • Hardware and Interfaces Usage CLI
        • LAB: Usage GPIO via CLI
        • LAB: Scan I2C bus via CLI
      • Python library for Crow Pi
      • wiringPi library (C) for CrowPi
        • Lab2: Crowpi and sensors
    • LVGL Development
      • LVGL - Light and Versatile Embedded Graphics Library
        • Setting program for LVGL Simulator
        • Get started with LVGL simulator
        • Example Library of LVGL
        • Create your own screen
          • Exercise
        • Style
          • Exercise
        • Event
    • Docker OS
      • Docker OS Part 1
        • Part 1 : Installation
        • Part 2 : Basic Docker OS and Linux CLI
      • Docker OS Part 2
        • Part 1 : Docker communication
        • Part 2 : Docker compose
      • Application Gstreamer on devcontainer
        • STEP 1 : Setting gstreamer environment
        • STEP 2 : Create the Gstreamer element on template
        • STEP 3 : Testing and application on your gst element
  • 🤟Recommended by AIC
    • Skill Roadmap
      • Embedded Engineer
      • Developer
    • Hardware Programming
    • Embedded Programming
    • General-propose Programming
    • Algorithmica
    • Thai Expert Knowledge
    • RT-Thread University Program
      • Infineon PSoC6
      • Kernel
        • Kernel Basics
        • Thread Management
        • Clock Management
        • Inter-thread synchronization
        • Inter-thread communication
        • Memory Management
        • Interrupt Management
        • Kernel porting
        • Atomic Operations
        • RT-Thread SMP
        • Kernel API Changelog
      • Tools
      • Devices & Drivers
        • SENSOR Devices
        • Touch Equipment
        • CRYPTO Devices
        • AUDIO Devices
        • Pulse Encoder Devices
      • Components
        • C Library (libc)
        • ISO/ANSI C Standard
        • POSIX Standard
          • FILE (File IO)
          • Pthread
          • Timer
          • IPC Semaphore
          • IPC Message Queues
          • Dynamic Modules
        • Network Components
          • FinSH Console
          • FAL: Flash Abstraction Layer
          • Virtual File System
          • tmpfs: temporary file system
          • ulog log
          • utest testing framework
          • Power Management
          • RT-Link
        • Software Packages
          • Internet of Things
            • MQTT-umqtt
            • Telnet
          • Tools
            • SystemView
            • SEGGER_RTT
          • LVGL Manual
            • Touch Screen Driver
      • Demo
        • Infineon Gateway
        • Handwriting Recognition (MNIST)
        • Object Detection (Darknet)
        • ROS using RT-Thread
        • Control the car using RT-Thread
        • LiDAR via RT-Thread
        • Detection via RT-Thread and ROS
        • Sensor Driver Development Guide
Powered by GitBook

Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University

On this page
  • 1. Introduction to FAL
  • 2. Use FAL
  • 3. MSH test command
  • 4. Common applications
  • 5. Frequently Asked Questions

Was this helpful?

  1. Recommended by AIC
  2. RT-Thread University Program
  3. Components
  4. Network Components

FAL: Flash Abstraction Layer

PreviousFinSH ConsoleNextVirtual File System

Last updated 7 months ago

Was this helpful?

FAL: Flash Abstraction Layer, In V4.1.0, the fal package is redefined as an internal component of RT-Thread. The usage is different from before: (1) Originally, to use fal, you had to select and download it in the RT-Thread package manager; (2) Now you only need to open it in the component to use it. The following is a detailed introduction.

FAL (Flash Abstraction Layer) Flash abstraction layer is an abstraction layer for managing and operating Flash and Flash-based partitions. It unifies the Flash and partition operation APIs of the upper layer (the framework diagram is shown below) and has the following features:

  • Supports statically configurable partition tables and can associate multiple Flash devices;

  • The partition table supports automatic loading . This avoids the problem of partition tables being defined multiple times in multiple firmware projects.

  • The code is concise and has no dependency on the operating system . It can run on bare metal platforms, such as bootloaders that have certain resource requirements.

  • Unified operation interface. Ensures the reusability of the underlying Flash driver for components that have a certain dependency on Flash, such as the file system, OTA, and NVM (e.g.

  • It comes with Finsh/MSH-based test commands, which can operate (read, write, erase) Flash or partitions in byte-addressing mode through Shell, making it convenient for developers to debug and test;

FAL framework

Open and use in the component:

The configuration instructions for each function are as follows:

  • Enable debug log output (enabled by default);

  • Whether the partition table fal_cfg.his defined in (enabled by default). If this option is disabled, fal will automatically retrieve and load the partition table from the specified location of the specified Flash. For detailed configuration, see the following two options;

    • Flash device storing the partition table;

    • The end address of the partition table is located at the offset on the Flash device. fal will retrieve the partition table from this address and read directly to the top of the Flash. If you are not sure about the exact location of the partition table, you can also configure it as the end address of the Flash. fal will retrieve the entire Flash, and the retrieval time may increase.

  • Enable FAL porting files for SFUD (off by default);

    • The FLASH device name passed in when calling the function should be entered rt_sfud_flash_probe(you can also obtain it by viewing the Block Device name through the list_device command). This name corresponds to the Flash name in the partition table. Only by setting the device name correctly can the read and write operations on the FLASH be completed.

Then let the RT-Thread package manager automatically update, or use pkgs --updatethe command to update the package to the BSP.

name

illustrate

inc

Header file directory

src

Source code directory

samples

Routine Directory

The basic steps for using FAL are as follows:

  1. Open FAL: Open the fal package from Env and download it to the project.

  2. FAL transplantation: define flash device, define flash device table, define flash partition table. The following mainly explains step 2.

  3. Call fal_init() to initialize the library: After the porting is completed, it can be called in the application layer, such as in the main function.

Before defining the Flash device table, you need to define the Flash device first. It can be on-chip flash or off-chip spi flash based on SFUD:

Define a specific Flash device object. Users need to implement init,,, readand these operation functions according writeto their own Flash situation:erase

  • static int init(void): Optional initialization operation.

  • static int read(long offset, uint8_t *buf, size_t size): Read operation.

parameter

describe

offset

Flash offset address to read data from

buf

Buffer for storing data to be read

size

The size of the data to be read

return

Returns the actual size of the data read

  • static int write(long offset, const uint8_t *buf, size_t size): Write operation.

parameter

describe

offset

Flash offset address to write data to

buf

Buffer for storing data to be written

size

The size of the data to be written

return

Returns the actual size of the data written

  • static int erase(long offset, size_t size): Erase operation.

parameter

describe

offset

Flash offset address of erase area

size

Size of the erase area

return

Returns the size of the area actually erased

Users need to implement these operation functions according to their own Flash situation. The specific Flash device object is defined at the bottom of the file. The following example defines the stm32f2 on-chip flash: stm32f2_onchip_flash

const struct fal_flash_dev stm32f2_onchip_flash =
{
    .name       = "stm32_onchip",
    .addr       = 0x08000000,
    .len        = 1024*1024,
    .blk_size   = 128*1024,
    .ops        = {init, read, write, erase},
    .write_gran = 8
};copymistakeCopy Success
  • "stm32_onchip": The name of the Flash device.

  • 0x08000000: The starting address for Flash operation.

  • 1024*1024: Total size of the Flash (1MB).

  • 128*1024: Flash block/sector size (because the sizes of STM32F2 blocks are uneven, the erase granularity is the size of the largest block: 128K).

  • {init, read, write, erase}:Flash operation function. If there is no init initialization process, the first operation function position can be left blank.

  • 8: Set the write granularity, unit is bit, 0 means it is not effective (the default value is 0). This member is a new member of the fal version greater than 0.4.0. The write granularity of each flash is different, and it can be set through this member. The following are some common flash write granularities:

    • nor flash: 1 bit

    • stm32f4: 8 bits

    • stm32f1: 32 bit

    • stm32l4: 64 bit

Device table example:

/* ===================== Flash device Configuration ========================= */
extern const struct fal_flash_dev stm32f2_onchip_flash;
extern struct fal_flash_dev nor_flash0;

/* flash device table */
#define FAL_FLASH_DEV_TABLE                                          \
{                                                                    \
    &stm32f2_onchip_flash,                                           \
    &nor_flash0,                                                     \
}copymistakeCopy Success

In the Flash device table, there are two Flash objects, one is the on-chip Flash of STM32F2, and the other is the off-chip Nor Flash.

Partition table example:

#define NOR_FLASH_DEV_NAME             "norflash0"
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#define FAL_PART_TABLE                                                               \
{                                                                                    \
    {FAL_PART_MAGIC_WORD,        "bl",     "stm32_onchip",         0,   64*1024, 0}, \
    {FAL_PART_MAGIC_WORD,       "app",     "stm32_onchip",   64*1024,  704*1024, 0}, \
    {FAL_PART_MAGIC_WORD, "easyflash", NOR_FLASH_DEV_NAME,         0, 1024*1024, 0}, \
    {FAL_PART_MAGIC_WORD,  "download", NOR_FLASH_DEV_NAME, 1024*1024, 1024*1024, 0}, \
}
#endif /* FAL_PART_HAS_TABLE_CFG */copymistakeCopy Success

The above partition table describes the information in detail as follows:

Partition name

Flash device name

Offset Address

size

illustrate

"bl"

"stm32_onchip"

0

64KB

Bootloader

"app"

"stm32_onchip"

64*1024

704KB

app

"easyflash"

"norflash0"

0

1MB

EasyFlash parameter storage

"download"

"norflash0"

1024*1024

1MB

OTA Download Area

The partition parameters that users need to modify include: partition name, associated Flash device name, offset address (relative to the Flash device), size, and the following points should be noted:

  • Partition names must not be repeated ;

  • The associated Flash device must have been defined in the Flash device table and have the same name , otherwise an error will occur that the Flash device cannot be found;

  • The starting address and size of the partition cannot exceed the address range of the Flash device , otherwise it will cause package initialization errors;

Note: When defining each partition, in addition to filling in the parameter attributes described above, you need to add FAL_PART_MAGIC_WORDthe attribute at the front and add the attribute at the end 0(currently used to retain the function)

fal provides a variety of test commands. All the project needs to do is enable the MSH function on RT-Thread. These commands are very useful when developing and debugging Flash-based applications. It can accurately write or read the original Flash data at a specified location, quickly verify the integrity of the Flash driver, and even perform performance tests on Flash.

The specific functions are as follows: Enter fal to see a complete list of commands

msh />fal
Usage:
fal probe [dev_name|part_name]   - probe flash device or partition by given name
fal read addr size               - read 'size' bytes starting at 'addr'
fal write addr data1 ... dataN   - write some bytes 'data' starting at 'addr'
fal erase addr size              - erase 'size' bytes starting at 'addr'
fal bench <blk_size>             - benchmark test with per block size

msh />copymistakeCopy Success

When you use the fall command for the first time, directly inputting fal probe will display the partition table information. You can specify the object to be operated as a partition in the partition table or a Flash device.

After the partition or Flash is successfully selected, some of its properties will be displayed. The general effect is as follows:

msh />fal probe    
No flash device or partition was probed.
Usage: fal probe [dev_name|part_name]   - probe flash device or partition by given name.
[I/FAL] ==================== FAL partition table ====================
[I/FAL] | name      | flash_dev    |   offset   |    length  |
[I/FAL] -------------------------------------------------------------
[I/FAL] | bl        | stm32_onchip | 0x00000000 | 0x00010000 |
[I/FAL] | app       | stm32_onchip | 0x00010000 | 0x000b0000 |
[I/FAL] | ef        | norflash0    | 0x00000000 | 0x00100000 |
[I/FAL] | download  | norflash0    | 0x00100000 | 0x00100000 |
[I/FAL] =============================================================
msh />
msh />fal probe download
Probed a flash partition | download | flash_dev: norflash0 | offset: 1048576 | len: 1048576 |.
msh />copymistakeCopy Success

Enter first fal erase, followed by the starting address and length of the data to be erased. The following command is: Erase 4096 bytes of data starting from address 0 (relative to Flash or partition)

Note: According to the Flash characteristics, the erase operation will be processed according to the sector alignment. Therefore, if the erase operation address or length is not aligned with the Flash sector, the entire sector data associated with it will be erased.

msh />fal erase 0 4096
Erase data success. Start from 0x00000000, size is 4096.
msh />copymistakeCopy Success

Enter first fal write, followed by N data to be written, separated by spaces. The following command is: Write 1, 2, 3, 4, 5 bytes of data in sequence starting from address 8

msh />fal write 8 1 2 3 4 5
Write data success. Start from 0x00000008, size is 5.
Write data: 1 2 3 4 5 .
msh />copymistakeCopy Success

Enter first fal read, followed by the starting address and length of the data to be read. The following command is: read 64 bytes of data starting from address 0

msh />fal read 0 64
Read data success. Start from 0x00000000, size is 64. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00000000] FF FF FF FF FF FF FF FF 01 02 03 04 05 FF FF FF 
[00000010] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
[00000020] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
[00000030] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

msh />copymistakeCopy Success

The performance test will test the erasing, writing and reading speed of the Flash, and will also test the accuracy of the written and read data to ensure the consistency of the written and read data of the entire Flash or the entire partition.

Enter first fal bench, followed by the sector size of the Flash to be tested (please check the corresponding Flash manual, SPI Nor Flash is generally 4096). Since the performance test will cause the data of the entire Flash or the entire partition to be lost, the command must be followed at the end yes.

msh />fal bench 4096 yes
Erasing 1048576 bytes data, waiting...
Erase benchmark success, total time: 2.674S.
Writing 1048576 bytes data, waiting...
Write benchmark success, total time: 7.107S.
Reading 1048576 bytes data, waiting...
Read benchmark success, total time: 2.716S.
msh />copymistakeCopy Success

fal_cfg.h1. Unable to find header file when using FAL

fal_cfg.hThis is the configuration file of the fal package. It needs to be created manually by the user and define the relevant partition table information. Please put this file in the port folder of the BSP or the port folder of the project directory (if it does not exist, create a new port folder) and add the header file path to the project. For details, see the " 2.2、定义 flash 设备表" section of this article.

After adding the file, check the file contents fal_cfg.hin the folder where the file is located or in the folder above it . For example, if the file is in the folder, check whether the file has the following contents:SConscriptfal_cfg.hstm32f072-st-nucleo/board/portsstm32f072-st-nucleo\board\SConscript

path =  [cwd]
path += [cwd + '/ports']copymistakeCopy Success

The above is used to fal_cfg.hadd the file path to the project.

1649928016219

The FAL-related API is shown in the figure. .

FAL API

fal transplant

For more information on defining off-chip spi flash devices, see .

For more information on defining on-chip flash devices, see .

The Flash device table is defined in fal_cfg.hthe header file. Before defining the partition table, you need to create a new fal_cfg.hfile . Please put the file in the port folder of the corresponding BSP or project directory and add the header file path to the project. fal_cfg.h can be completed by referring to .

The partition table is also defined in fal_cfg.hthe header file. Flash partitions are based on Flash devices. Each Flash device can have N partitions. The collection of these partitions is the partition table. Before configuring the partition table, make sure that the Flash device and device table have been defined . fal_cfg.h can be completed by referring to .

🤟
1.1. Open FAL
1.2 FAL Directory
1.3 FAL API
Click here to view the detailed explanation of API parameters
2. Use FAL
2.1、Define flash device
fal_flash_sfud_port.c
fal_flash_stm32f2_port.c
2.2. Define the flash device table
the sample file fal/samples/porting/fal_cfg.h
2.3. Define the flash partition table
the sample file fal/samples/porting/fal_cfg.h
3. MSH test command
3.1、Specify the Flash device or Flash partition to be operated
3.2. Erase Data
3.3. Write data
3.4. Reading Data
3.5 Performance Testing
4. Common applications
fatfs file system routine based on FAL partition
Littlefs file system based on FAL partition application note
EasyFlash migration instructions based on FAL partition
5. Frequently Asked Questions
1. Introduction to FAL
EasyFlash );