Latest Posts
The built-in Bootloader of the chip updates the program to the Flash through the burner, via the chip manufacturer’s agreement.
Memory SD Card: A Comprehensive Guide
Basic Types of Memory SD Card
I have extensive experience in Bootloader upgrade projects, and I find Bootloaders to be truly fascinating. Essentially, a Bootloader enables you to update the remaining programs on a chip via a specific section of the program. This, in turn, allows for the updating of the product software. The built-in Bootloader of the chip updates the program to the Flash memory through a burner, following the chip manufacturer’s protocol.
There are several common types of Memory SD Cards:
Type | Characteristics | Applicable Scenarios |
---|---|---|
SD | The most common type, with different size standards such as SD, miniSD, and microSD. | Traditional cameras, some older devices. |
SDHC (Secure Digital High Capacity) | Capacity ranges from 4GB to 32GB, supporting higher data transfer speeds. | Most modern digital cameras, camcorders. |
SDXC (Secure Digital Extended Capacity) | Capacity can reach up to several TB, meeting the storage needs of users who require high-capacity storage, such as for high-definition video recording. | Professional photography and videography equipment, high-end smartphones for storing large amounts of data. |
Performance Indicators of Memory SD Card
There are multiple ways to perform Bootloader upgrades. Theoretically, almost all communication methods can be used for this purpose, including CAN, SPI, IIC, USART, etc. I have personal experience with CAN upgrade, USART upgrade, SD card upgrade, and OTA upgrade in automotive applications. CAN upgrade and USART upgrade are both online upgrade methods. In contrast, the SD card upgrade can be considered an offline upgrade, which means you can upgrade an SD card without using a PC terminal. (Although, if there are hardware upgrade devices, CAN and USART can also be used for offline upgrades.)
The following are the key performance indicators of Memory SD Cards:
Performance Indicator | Description | Importance |
---|---|---|
Capacity | Represents the amount of data that the SD card can store, measured in GB or TB. | Choose an appropriate capacity based on device requirements and personal usage habits. For example, 64GB – 128GB is suitable for ordinary home users who mainly record daily photos and short videos, while professional video shooters may need 1TB or more. |
Read/Write Speed | The speed at which data can be read from and written to the SD card, typically measured in MB/s. | For devices that require high-speed data operations such as burst photo shooting and high-definition video recording, a high read/write speed is crucial. For example, the write speed of an SD card with the UHS – I U3 standard can reach up to 90MB/s or more. |
Durability | Includes characteristics such as shock resistance, drop resistance, high-temperature resistance, and low-temperature resistance. | For devices used in outdoor adventures and sports photography, a highly durable SD card is necessary. |
How to Choose a Suitable Memory SD Card
When choosing a Memory SD Card, consider the following factors:
- Device Compatibility: Different devices have different requirements for the type, size, and speed of SD cards. For example, some older digital cameras may only support SD cards, while newer smartphones may be more suitable for microSD cards.
- Capacity and Speed Requirements: Ordinary home users who mainly record daily life photos and short videos can choose an SD card with a capacity of 64GB – 128GB and a moderate read/write speed. Professional photographers or video creators may need high-capacity (such as 1TB or more) and high-speed (UHS – II standard or higher) SD cards to ensure fast data storage and high-quality video recording.
Brand Recommendations for Memory SD Card
Here are some recommended brands for Memory SD Cards:
Brand | Advantages |
---|---|
SanDisk | High brand awareness, a wide variety of products, stable and reliable performance, and a good reputation in the market. |
Kingston | Offers SD cards in multiple capacities, with a good cost-performance ratio. Its products perform well in terms of compatibility and durability. |
Samsung | Known for its high-quality storage chips, providing fast read/write speeds. Suitable for users with high performance requirements. |
SD Card Bootloader Using STM32F103RCT6 Chip
In this section, we will use the STM32F103RCT6 chip to create an SD card Bootloader. Here are the detailed steps and related explanations:
Software Components
(register coding, in order to reduce the space occupied by Bootloader code)
SPI Driver Initialization
Initialize SPI1 using the `SPI1_Init()` function. Use `SPI1_ReadWriteByte` for reading and writing operations.
SD Card Driver and FATFS File System
Pre-written programs for reading, writing, and initializing the SD card are used directly. FATFS file system is employed, and two files need to be transplanted. (Details of these steps are not covered here.)
Chip Flash Operation
Since flash operations are required during APP program unprogramming, the flash erasing and writing processes are essential.
APP Program Jump-in
When the updated program is written to the Flash, it needs to jump to the starting address of the Flash. A specific function is executed for this purpose.
Application Part
Select a starting address, which should be greater than the total length of the Bootloader program and ensure that the length of the APP program does not exceed (chip size – Bootloader program size). Choose an address in the Flash as a flag point to determine whether the program needs to be updated. Read the file from the SD card, write the data into the corresponding Flash, and complete the jump.
Main Function Flow
- Check Flag Point: The main function first checks the flag point at address 0x08002FFE. If it is 0x02, it indicates that there is an existing APP program and no update is needed. In this case, `iap_load_app(FLASH_APP_ADDR)` is used to jump to the starting address of the APP and run the program, ending the BOOT program.
- Initiate Upgrade: If the flag point is not 0x02, it implies that it is a new chip or one that has not been upgraded before. The upgrading process is then started using the `SD_Update()` function of the BOOT program.
- Upgrade Operations:
- File Reading and Flash Erasing/Writing: Use `f_read` to read the file from the SD card and store it in the buffer array. `STM_FLASH_ErasePage` erases a Flash area, and `STM_FLASH_WriteHalfWord` writes data. After writing, `PageOffest += STM_PAGE_SIZE` records the number of pages written, and the process continues by reading the next portion of the file (in chunks of STM_PAGE_SIZE). This continues until `(res || br = 0)`, indicating no more readable content, at which point the loop breaks.
- Flag Address Update: Erase the flagged address using `STM_FLASH_ErasePage(0x08002FFE)` and write 0xFF02. This marks the presence of an APP program so that the next time the card is powered on, it will be recognized as having an APP program, allowing a direct jump to the APP address.
- End of Bootloader Process: Finally, `iap_load_app(FLASH_APP_ADDR)` marks the end of the Bootloader process for the SD card, and the system enters the APP program to run.
Conclusion
In conclusion, understanding the intricacies of Memory SD Cards, especially when it comes to Bootloader operations, is crucial for various applications. Whether you’re a hobbyist or a professional, this knowledge can help you make informed decisions and troubleshoot issues effectively.
Leave a comment