spacemeowx2 / blflash

bl602 serial flasher
Apache License 2.0
54 stars 15 forks source link

Completly clear flash? #7

Open OevreFlataeker opened 2 years ago

OevreFlataeker commented 2 years ago

I am not sure where the problem is actually rooted but after some playing around, Wifi related stuff for my BL602 does not seem to work anymore. The SDK's demo bl602_demo_wifi flashes correctly but immediately gets into a reboot loop when booting the system. The sdk_app_http_client_socket firmware just prints on all WiFi related stuff "Wait Wi-Fi Mgr Startup..." in an endless loop.

I presume there is some junk somewhere in the flash memory left from previous attempts that now cause a problem. Is there a way to fully erase the flash with blflash so I can be sure everything is clean and tidy before reflashing a new firmware?

OevreFlataeker commented 2 years ago

2021-07-10_16-22-03

This is what I see in an endless loop for those firmwares. It seems to access some area in memory, fails and hard faults/reboots

spacemeowx2 commented 2 years ago

Sorry for taking so long to reply. Please correct me if I am wrong. BL602 has its built-in boot loader, which reads Flash in a specific format and load it into memory in runtime. So blflash will only write the necessary data. The rest of the data should not be loaded into memory(or mapping to address).

I am not an expert in bl602, but I think it maybe something wrong with dtb. You can see all flash options by running blflash flash --help.

OevreFlataeker commented 2 years ago

It might well be the DTB. Thing is that I got another DT BL10 board which immediately works correctly performing the same steps as with my bricked(?) Magichome board (i.e. also using the same DTB). blflash will also apply the DTB definitions, won't it?

spacemeowx2 commented 2 years ago

By default, blflash will apply a built-in dtb even if no dtb parameter is specified. See ro_params.dtb.

OevreFlataeker commented 2 years ago

This was my understanding as well... so if i am able to use a vanilla compile of blflash and bl_iot_sdk and it works on the 2nd board everything should be fine and the same setup should also correctly flash/run on the Magichome board... alas it does not... :-( Could a potentially wrong flashed dtb have caused any damage on that board maybe? I did play around with baudrate of 115200 in the dtb once when I did not have a modern USB-UART but that was the only change and I reverted everything and flashed the 2M dtb in all future runs....

magnushiie commented 2 years ago

I have the same issue, mucked around with dtbs and now the board restarts even with the default dtb. I disabled automatic WiFi stack startup so I can definitely verify that it's WiFi-related - the reboot happens when I issue the stack_wifi command:

# stack_wifi
Start Wi-Fi fw @17795ms
1th channel,lo_vco_freq_cw=149
2th channel,lo_vco_freq_cw=147
3th channel,lo_vco_freq_cw=146
4th channel,lo_vco_freq_cw=145
5th channel,lo_vco_freq_cw=143
6th channel,lo_vco_freq_cw=142
7th channel,lo_vco_freq_cw=141
8th channel,lo_vco_freq_cw=140
9th channel,lo_vco_freq_cw=138
10th channel,lo_vco_freq_cw=137
11th channel,lo_vco_freq_cw=136
12th channel,lo_vco_freq_cw=135
13th channel,lo_vco_freq_cw=134
14th channel,lo_vco_freq_cw=132
15th channel,lo_vco_freq_cw=131
16th channel,lo_vco_freq_cw=130
17th channel,lo_vco_freq_cw=129
18th channel,lo_vco_freq_cw=128
19th channel,lo_vco_freq_cw=126
20th channel,lo_vco_freq_cw=125
21th channel,lo_vco_freq_cw=124
0th channel,vco_idac_cw=13
1th channel,vco_idac_cw=13
2th channel,vco_idac_cw=13
3th channel,vco_idac_cw=13
4th channel,vco_idac_cw=12
5th channel,vco_idac_cw=12
6th channel,vco_idac_cw=12
7th channel,vco_idac_cw=12
8th channel,vco_idac_cw=12
9th channel,vco_idac_cw=12
10th channel,vco_idac_cw=12
11th channel,vco_idac_cw=12
12th channel,vco_idac_cw=12
13th channel,vco_idac_cw=12
14th channel,vco_idac_cw=12
15th channel,vco_idac_cw=12
16th channel,vco_idac_cw=12
17th channel,vco_idac_cw=12
18th channel,vco_idac_cw=11
19th channel,vco_idac_cw=11
20th channel,vco_idac_cw=11
LO locked 9 137
rosdac_i_gc3=29
rosdac_i_gc2=29
rosdac_i_gc1=29
rosdac_i_gc0=29
rosdac_q_gc3=37
rosdac_q_gc2=37
rosdac_q_gc1=37
rosdac_q_gc0=37
rbb_cap1_fc_i=20,rbb_cap2_fc_i=20,rbb_cap1_fc_q=20,rbb_cap2_fc_q=20
new rbb_cap1_fc_i=44,rbb_cap2_fc_i=44,rbb_cap1_fc_q=44,Starting bl602 now....
Booting BL602 Chip...
OevreFlataeker commented 2 years ago

Interesting... Seems to match my observations. Any idea what might be the underlying cause? Could a DTB performa a persistent change in the SoC?

normanr commented 2 years ago

See also https://github.com/apache/incubator-nuttx/issues/4336. When building NuttX I need to use https://github.com/xouillet/bl_rfbin to merge the device tree otherwise Wifi doesn't work. Maybe it can also be used to reset the DTB?