5 SiFli¶
5.1 Where is the misconfiguration that caused the Impeller download to fail?¶
Root cause: 16M flash, ER_IROM3 specifies an address beyond the 16M flash 0x00000-0xFFFFFF address range,
Solution: 1. The method of trimming watchdemo in SDK to 16M flash is shown in the figure below:
After compiling, the download address can be found from the hex file format, as shown in the figure below:
5.2 Double-clicking butterfli.exe in the solution does not open the compilation tool¶
a、Open the display settings of the PC or laptop and set the percentage to 100%.(Other resolution percentage sizes are also acceptable,但需要保证butterfli.exe的页面显示正常)
b、Ensure that the following options are enabled in Display - Advanced Scaling Settings, otherwise the page size may change but some tools remain the same size when opened, and butterfli.exe may still not open:
c、The normal display of the butterfli.exe tool interface is as follows. If the display is disordered, please adjust the resolution and display percentage.
5.3 console finsh shellcommand,How to read and write register values with regop?¶
regop unlock 0000 # Need to unlock first
regop read 40070018 2 # Hexadecimal cannot have the 0x prefix
regop read 4007001c 1
regop write 40007100 200 # Hexadecimal cannot have the 0x prefix
5.4 Method to check if the 48M crystal has been calibrated for frequency offset¶
1,Enter the command: crystal_get in the hcpu serial command line, if a non-zero or 0xFF value is returned, it proves that the board has been calibrated, as shown in the figure below:
uncalibrated,Return as follows:
msh />crystal_get
FACTORY_CFG_ID_CRYSTAL read failed with 0
对应代码:
int32_t crystal_get(int32_t argc, char **argv)
{
int res;
uint32_t cal_value;
res = rt_flash_config_read(FACTORY_CFG_ID_CRYSTAL, (uint8_t *)&cal_value, sizeof(cal_value));
if (res <= 0)
{
rt_kprintf("FACTORY_CFG_ID_CRYSTAL read fail with %d\n", res);
return -1;
}
else
{
rt_kprintf("Get CRYSTAL cal_value 0x%x\n", cal_value);
}
return 0;
}
MSH_CMD_EXPORT(crystal_get, crystal_get);
2,The 56x series solution code uses otp_factory_read to read all otp partition data, as shown in the figure below:
5.5 Method to generate Source Insight project file list¶
1,After SDK v1.1.3, the scons --target=si
command was added, which can generate a file list si_filelist.txt
that only participates in the compilation
In commands that require specifying --board=em-lb525
for compilation, you need to add the board parameter, the commands are as follows:
scons --target=si
scons --board=em-lb525 --target=si
2,After creating a new project in the SourceInsight tool, you can select menu: project -> Add and Remove Project Files -> Add from list...
to import the generated si_filelist.txt
into the project for easy code viewing
5.6 Method for 55X to view OTP/Flash data in the chip factory calibration area¶
1,Can be used to check whether ADC and crystal are calibrated, whether they are overwritten, and serial number, Bluetooth address, name, etc.
Below are the operating instructions:
otp_debug_0922.7z
a, Ensure that jlink can connect normally to the sifli machine, if not, pull MODE high, then reset the machine.
b,Run the test.bat batch command in otp_debug_0922.7z, it will burn the factory_cali.bin file into RAM and jump to that RAM address to run, without affecting the original flash program.
c,Run JLinkRTTViewer.exe, select Auto Detection as the connection method, enter help to return the command, then you can enter the command to read the OTP data of the chip.
d,Otp_read 0 1 /This command reads all OTP/
Refer to the following operation process:
00> Serial:c2, Chip:1, Package:0, Rev:80
00> \ | /
00> - SiFli Corporation
00> / | \ Built on Aug 18, 2022, 1.1.1 build 4df1cb
00> 2020 - 2021 Copyright by SiFli team
00> Debug: Main thread running
00> msh >
< help
00> help
00> RT-Thread shell commands:
00> list_mem - List memory usage information
00> memcheck - Check memory data
00> memtrace - Dump memory trace information
00> pin - Pin GPIO functions
00> uart - UART setting
00> reboot - Reboot System
00> regop - Register read/write
00> pwr_ctrl - BLE TX power adjustment
00> crystal_cali - Crystal_cali 8 5 20 (PB08 5ppm 20s)
00> Crystal_cali_get - Crystal_cali_get
00> Crystal_cali_set - Crystal_cali_set 0x1EA
00> otp_reset - Otp_reset 0
00> otp_read - Otp_read 0 1
00> Battery_get - Battery_get
00> battery_r_set - Battery_r_set 1000 220
00> battery_cali_set - Battery_cali_set 10000 0
00> Battery_cali_get - Battery_cali_get
00> battery_cali - Battery_cali 4000 400 10 1000 220 (4000mV +-400mV +-10mv 1000k 220k)
00> Efuse_uid_read - Efuse_uid_read
00> Otp_fwenc_read - Otp_fwenc_read
00> Fw_enc_wr - Fw_enc_wr
00> hcpu_jump_run - hcpu_jump_run addr (eg: hcpu_jump_run 0x10020000)
00> lcpu - forward lcpu command
00> sysinfo - Show system information
00> adc - adc function
00> version - show RT - Thread version information
00> list_event - list event in system
00> list_mailbox - list mail box in system
00> list_msgqueue - list message queue in system
00> list_memheap - list memory heap in system
00> exit - return to RT - Thread shell mode.
00> console - Change MSH / FINSH console device.
00> help - RT - Thread shell help.
00> time - Execute command with time.
00> free - Show the memory usage in the system.
00>
00> msh >
< Otp_read 0 1
00> Otp_read 0 1
00> READ otp addr 0x1000 with res 256
00> 0x06 0x04 0x0d 0x6b 0x07 0x06 0x04 0x04
00> 0x9f 0x81 0xfb 0x82 0xff 0xff 0xff 0xff
00> 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
00> 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
00> 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
00> 0xff 0xff 0xff 0xff
00> ULOG_WARN: trace loss 97,521
2,OTP数据解读:
The data in OTP is arranged in the order of ID+LEN+DATA.
a,ID occupies one byte, and several IDs are defined in the header file.LEN occupies one byte, which limits the content of an ID not to exceed 255 bytes.
DATA is the actual data, stored in the data format defined by ID itself, OTP does not care about the actual data.
Each ID is tightly packed without any other sync words, so the query must start from the beginning, searching for each ID one by one.
b,When modifying existing ID data,first start searching from the beginning,locate the corresponding ID,check the length,if the newly set length is the same as the previous length,then the data is saved to the same location,
if the length changes,then the subsequent ID data moves forward,and then place the modified ID at the end。
#define FACTORY_CFG_ID_INVALID 0 /*!< Invalid ID */
#define FACTORY_CFG_ID_MAC 1 /*!< BLE MAC address */
#define FACTORY_CFG_ID_SN 2 /*!< Serial Number */
#define FACTORY_CFG_ID_CRYSTAL 3 /*!< Crystal tuning information */
#define FACTORY_CFG_ID_ADC 4 /*!< ADC tuning information*/
#define FACTORY_CFG_ID_SDMADC 5 /*!< SDMADC tuning information*/
#define FACTORY_CFG_ID_VBUCK 6 /*!< VBUCK /LDO information*/
#define FACTORY_CFG_ID_SECCODE 7 /*!< Security Code or something like this*/
#define FACTORY_CFG_ID_LOCALNAME 8 /*!< BLE localname*/
#define FACTORY_CFG_ID_BATTERY 9 /*!< Battery verify value*/
#define FACTORY_CFG_ID_FWVERIFY 10 /*!< FW verify code generated based in uid*/
#define FACTORY_CFG_ID_ALIPAY_PK 11 /*!< for alipay product key code*/
#define FACTORY_CFG_ID_ALIPAY_DN 12 /*!< for alipay device name code*/
#define FACTORY_CFG_ID_ALIPAY_DS 13 /*!< for alipay device secret code*/
#define FACTORY_CFG_ID_UNINIT 0xFF /*!< Uninitialized ID */
如下图的解析:
The ID inside the red box: 0x06 is FACTORY_CFG_ID_VBUCK, the data length 0x04 is the data length, followed by 0x0d, 0x6b, 0x05, 0x06 as data.
The ID inside the blue box is 0x04, corresponding to ADC calibration data, ATE has saved before the chip leaves the factory, ID 0x09 is the second calibration battery saved on the production line (not shown in the figure below), when calculating the battery voltage, the two combinations are used.
The ID inside the green box is 0x03, which is crystal calibration data.
下面是一例出现问题的OTP数据:
As shown in the figure below: only the data with ID=0x07 exists, other ADC calibration and crystal calibration data have been overwritten.
5.7 52X芯片Method to check if the chip is calibrated¶
The PMU’s AON_BG register will read the value from EFUSE during software initialization to update the register, if the register is not the default value 0x18, it can be considered that the chip has been calibrated, the specific method is as follows:
1,After normal booting, the code executes to BSP_System_Efuse_Config();
2, jlink.exe command mem32 0x500ca000 20
Check the value of the corresponding 0x24 register:
As follows, the corresponding 0x500ca024 register is 0x39, not the default 0x18, proving that it has been calibrated
5.8 Memory dump method¶
5.8.1 52x,56xSerial port memory dump method¶
Open the sdk\tools\crash_dump_analyser\script
directory, execute AssertDumpUart.exe, select the path to save bin, memory configuration, chip model (support 52x, 56x), serial port number, click export, start saving memory content as a bin file,
After the prompt is successful, put all the generated *.bin, *.txt, and the compiled axf files in one directory, then use the Trace32 tool to parse.
5.8.2 55x,56x,58x,J-Link memory dump method;¶
Open the sdk\tools\crash_dump_analyser\script
directory, as shown in the figure below, *.bat is the corresponding dump batch processing command, you can open it with a text editor to see the specific operations performed inside.
These three batch processes all use jlink for dumping. If jlink can connect to the device, you can execute the *.bat file corresponding to the memory that needs to be dumped, for example, the content after opening save_ram_55x.bat is as follows:
JLink.exe -Device CORTEX-M33 -CommanderScript sf32lb55x.jlink >log.txt
After connecting to jlink, it will call a series of commands in sf32lb55x.jlink (which can be opened to view and edit commands) to save registers and memory as bin operations, then the log of the dump process will be saved in log.txt, if the dump fails, you can open it to check the reason for failure.
After completion, *.bin, *.txt files
will be generated in the *.bat directory, put all the generated *.bin, *.txt
, and the compiled hcpu/lcpu/bootloader
axf files in one directory, then use the Trace32 tool to parse.