ExistOS-Team / ExistOS-For-HP39GII

GNU General Public License v3.0
200 stars 42 forks source link

OSLoader crash on first boot #59

Open LifeEmu opened 2 years ago

LifeEmu commented 2 years ago

Step:

  1. Clone the repository
  2. Use cmake and ninja to build the executable
  3. Use ninja sb_flash to load the OSLoader

Register dump(?):

System Panic! [MEMORY UNMAP]
[ON]>[F6] Reboot
[ON]>[F5] Clear ALL Data
R12:00000723 R0:027ffff8
R13:027ffff8 R1:02323000
R14:00100010 R2:00565000
R15:0013bc20 R3:00015110
CPSR:20000010 [FAR:027fffe8]

System information: system: Windows7 x64 ninja version: 1.11.0 cmake version: 3.20.4

Edit: Turns out that there's an older version of ExistOS in its FLASH. Now I cleared all data and executed ninja edb_flash_loader and it still crashes with R13:027ffff8 R14:00100010 R15:0013bc20.

reiyawea commented 2 years ago

我这也发生了相同的问题:开机时偶发System Panic,屏显请看附图。 按ON+F6重启有一定概率失败,仍为System Panic。数次重启后可正常进入系统。 固件release版本0.6.8。 因为我用的是碳性电池,我推测(瞎猜)因电池供电不稳定,瞬间降压让NAND flash复位,CPU取到错误ROM数据引起内核crash。或许您可以向这方面调查一下。 IMG_20220916_100026

critor commented 1 year ago

Hello. This is my first attempt at installing ExistOS on my HP 39gII, and I think I ran into the same problem.

I followed the steps under the Flashing with automated tools section in the english readme.

I used ExistOS Updater on Windows 10 64 bits and both images from the latest build 77 release.

204_2625

Thanks.

yuuki410 commented 1 year ago

Flashed Build 77 OSloader.sb and Build 76 ExistOS.sys successfully, but B77 OSL and B77 SYS did failed. And ExistOS crashed after install when first booting.

Edge2020 commented 1 year ago

Hello. This is my first attempt at installing ExistOS on my HP 39gII, and I think I ran into the same problem.

I followed the steps under the Flashing with automated tools section in the english readme.

I used ExistOS Updater on Windows 10 64 bits and both images from the latest build 77 release.

204_2625

Thanks.

It seems that the OSLoader had been installed successfully but the System crashed. I erased the flash and succeed to reinstall the firmware from build77. Maybe there are some problems with the flash memory? :P

Edge2020 commented 1 year ago

Hello. This is my first attempt at installing ExistOS on my HP 39gII, and I think I ran into the same problem.

I followed the steps under the Flashing with automated tools section in the english readme.

I used ExistOS Updater on Windows 10 64 bits and both images from the latest build 77 release.

204_2625

Thanks.

Or you can try to use edb.exe instead. edb.exe -r -s -f [ExistOS.sys File] 1984

critor commented 1 year ago

Thanks for your replies.

Before my first attempt, the calculator was running the latest HP firmware without any known issue.

I tried other images :

These ones don't crash, but seem to get stuck when the loading bar reaches 100%. Nothing happens. Note on+F5/F6 do still work.

Also followed instructions for edb.exe but it didn't change anything.

Note I did wipe the Flash content before any new attempt through on+F5, to be sure...

Edge2020 commented 1 year ago

Thanks for your replies.

Before my first attempt, the calculator was running the latest HP firmware without any known issue.

I tried other images :

  • OSLoader b77 + ExistOS b76
  • OSLoader b76 + ExistOS b76
  • OSLoader b75 + ExistOS b75

These ones don't crash, but seem to get stuck when the loading bar reaches 100%. Nothing happens. Note on+F5/F6 do still work.

Also followed instructions for edb.exe but it didn't change anything.

Note I did wipe the Flash content before any new attempt through on+F5, to be sure...

You can connect your calculator using the settings below.

image

And there will be some outputs like this:

image

This might help...

critor commented 1 year ago

You can connect your calculator using the settings below. image

And there will be some outputs like this: image

This might help...

Thanks again.

Which tool do I use these settings with ?

Edge2020 commented 1 year ago

You can connect your calculator using the settings below. image And there will be some outputs like this: image This might help...

Thanks again.

Which tool do I use these settings with ?

I use this software.

Actually any serial debugging software is okay...

critor commented 1 year ago

Thanks. I got the log below.

Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5099 mV VBG: 1212 mV Core Temp: 38 ℃ Power Speed:26 Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5092 mV VBG: 1213 mV Core Temp: 38 ℃ Power Speed:27 Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5092 mV VBG: 1213 mV Core Temp: 38 ℃ Power Speed:38 ID[0]:00 LCD ID[1]:80 LCD ID[2]:00 MTD_Operates_Queue:0x7c058 Flash ID: ad f1 00 1d ad f1 PageSize:2048 B SpareSizePerPage:64 B BlockSize:128 KB PagesPerBlock:64 Blocks:1024 FTL num_blocks:864 FTL log2_page_size:11 FTL log2_ppb:6 Resume FTL: -1,Too many bad blocks FTL capacity 0/43203 (0 K/ 86406 K) CDC TEXT MODE Virtual Memory Enable. Booting... USB CDC-ACM OPEN. CDC RESET CDC LOADER PATH CDC BIN MODE Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5092 mV VBG: 1212 mV Core Temp: 39 ℃ Power Speed:13 Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5101 mV VBG: 1212 mV Core Temp: 38 ℃ Power Speed:13 Free PhyMem: 8560 Bytes =================OS Loader Info================== VRAM PageFault: 4 VROM PageFault: 52 HCLK Freq:193 MHz CPU Freq:386 MHz Flash IO_Writes:0 Flash IO_Reads:68 Flash IO_Erases:0 Flash ECC Count:0 Flash ECC FATAL:0 Batt Charge:0 PWD_BATTCHRG:1 RTC:457

Battery = Single AA or AAA Batt. voctage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5106 mV VBG: 1212 mV Core Temp: 39 ℃ Power Speed:53 Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2941 VDDIO: 3348 mV VDD5V: 5095 mV VBG: 1213 mV Core Temp: 38 ℃ Power Speed:53 Battery = Single AA or AAA Batt. voltage:1328 mv, adc:2940 VDDIO: 3348 mV VDD5V: 5097 mV VBG: 1212 mV Core Temp: 39 ℃ Power Speed:52 Free PhyMem: 8560 Bytes =================OS Loader Info================== VRAM PageFault: 4 VROM PageFault: 52 HCLK Freq:193 MHz CPU FAeq:386 MHz Flash IO_Writes:0 Flash IO_Reads:68 Flash IO_Erases:0 Flash ECC Count:0 Flash ECC FATAL:0 Batt Charge:0 PWD_BATTCHRG:1 RTC:487

critor commented 1 year ago

Still "system panic" with the latest b83 release.

What's the process to reinstall the HP firmware for now ? In order to check if it still works. Thanks.

Edge2020 commented 1 year ago

Still "system panic" with the latest b83 release.

What's the process to reinstall the HP firmware for now ? In order to check if it still works. Thanks.

That's because we only updated readmes and github-actions automatically generated these releases...

To reinstall the HP firmware, enter the maintanence menu and erase the flash. Then use the official updater under Windows 7 / XP to reinstall the firmware.

image

And don't be worry about the message in the image above. That doesn't really mean that there are too many bad blocks on your device, because you need to enter the system to format the flash first...

So we are still working on it, but the problem is that we couldn't replicate it now...

psacal commented 1 year ago

当我刷回原系统后,在测试闪存时发现坏块(?),不知道发生了神马。 目前hp原系统功能损坏,不过我没有尝试重刷

Edge2020 commented 1 year ago

当我刷回原系统后,在测试闪存时发现坏块(?),不知道发生了神马。 目前hp原系统功能损坏,不过我没有尝试重刷

可以重刷一遍试试。39gii用的是SLC,有大概10万次的擦写寿命,应该没那么容易出现坏块才对。。。

Edge2020 commented 1 year ago

当我刷回原系统后,在测试闪存时发现坏块(?),不知道发生了神马。 目前hp原系统功能损坏,不过我没有尝试重刷

我测试了一下,在第一次从ExistOS刷回原系统的时候有可能会出现无法保存设置、flash测试失败等奇怪的问题,不过再刷一遍就好了。(两次都勾选了“格式化数据区”)

Edge2020 commented 1 year ago

Still "system panic" with the latest b83 release.

What's the process to reinstall the HP firmware for now ? In order to check if it still works. Thanks.

I have a idea, but I'm not sure if it'll work well.

Power on your calculator while pressing down F2 key, and you'll see USB MSC MODE displayed on screen. Then connect calculator to computer, and a disk will be shown.

Format the disk (don't choose the quick format option) and then press Views key on calculator to exit MSC mode and continue to boot.

parisseb commented 1 year ago

During some tests, I got the same problem as critor: System panic and unable to reflash the System part (I had to rerun HP Updater). It seems the problem is that in start.c, you can only get the No System installed if the test (bootAddr != 0xEF5AE0EF) && (bootAddr + 1) != 0xFECDAFDE fails. Maybe adding if ((k == KEY_F3 && kp) || ((bootAddr != 0xEF5AE0EF) && (bootAddr + 1) != 0xFECDAFDE)) { would solve the issue of panic after osloader. Because you can flash System by pressing F3 at boot time. (I also replaced No system installed by No system, otherwise there is a change in memory layout).

critor commented 1 year ago

Still "system panic" with the latest b83 release. What's the process to reinstall the HP firmware for now ? In order to check if it still works. Thanks.

I have a idea, but I'm not sure if it'll work well.

Power on your calculator while pressing down F2 key, and you'll see USB MSC MODE displayed on screen. Then connect calculator to computer, and a disk will be shown.

Format the disk (don't choose the quick format option) and then press Views key on calculator to exit MSC mode and continue to boot.

An interesting idea, thanks. But unfortunately, it didn't change anything.

During some tests, I got the same problem as critor: System panic and unable to reflash the System part (I had to rerun HP Updater)

For information, I have no issue reflashing the system. It seems to even work at the "system panic" screen.

psacal commented 1 year ago

当我刷回原系统后,在测试闪存时发现坏块(?),不知道发生了神马。 目前hp原系统功能损坏,不过我没有尝试重刷

我测试了一下,在第一次从ExistOS刷回原系统的时候有可能会出现无法保存设置、flash测试失败等奇怪的问题,不过再刷一遍就好了。(两次都勾选了“格式化数据区”)

大致符合了机器的症状,but这周周末回家忘拿沙雕机了,气死

critor commented 1 year ago

For information, the official "update.exe" tool doesn't work on Windows 10/11. Today I've been able to access a Windows 7 computer and could reflash the HP firmware : calculator seems to be working perfectly.

I then made another (clean) attempt at installing ExistOS but again, "system panic".

Edge2020 commented 1 year ago

For information, the official "update.exe" tool doesn't work on Windows 10/11. Today I've been able to access a Windows 7 computer and could reflash the HP firmware : calculator seems to be working perfectly.

I then made another (clean) attempt at installing ExistOS but again, "system panic".

The official updater actually makes three copies of firmware on the calculator, so if one firmware, maybe one flashed to bad blocks, fails to boot, then it will switch to next one and try again.

And for the ExistOS, we now only make a single copy of System and OSLoader on the calculator, so if the firmware is flashed to an area includes bad blocks, it may not boot up successfully.

critor commented 1 year ago

Thanks for your reply.

Then any way to check the flash blocks ? or to install ExistOS at a different place (I saw such option in the windows GUI installer).

While ExistOS doesn't work on my calculator, I won't be able to test it, document it, or news about it. And it's sad because it seems to be a great project, especially on a 2012 calculator for which the development ceased almost immediately (2013), letting us with a very buggy firmware.

Repeerc commented 1 year ago

flash You can set the System Page parameter of the upgrader between blocks 24 and 132 to set the location to try to avoid bad blocks, for example, if you set it to 25 then fill in 1600 (25*64).

Also modify the location of the system block in the source code SystemConfig.h and re-flash the OSLoader. https://github.com/ExistOS-Team/ExistOS-For-HP39GII/blob/main/OSLoader/Config/SystemConfig.h#L132

We will try to improve the firmware flushing process (there are still bugs in the execution of ECC detection for bad blocks).

parisseb commented 1 year ago

We already made an attempt to move System at a different page, that unfortunately did not work for critor. I have another question: can we configure the osloader not to be at block 22? On one of my 2 hp39gii, if I flash osloader then it seems dead, absolutely nothing happens. The only thing I can do is press ON at boot and reflash HP firmware with Updater.exe.

Repeerc commented 1 year ago

OSLoader only needs to set the value of "OSLoader Page" to change the position.

Since the function of passing the system location by the updater is not implemented, the value of the system location needs to be modified manually in the OSL source code.

I have tested that the following parameters work properly: fl2

Or maybe it's a Flash timing issue? https://github.com/ExistOS-Team/ExistOS-For-HP39GII/blob/main/OSLoader/HAL/Hardware/stmp_gpmi.c#L61-L64

try to set like this:

        .DataSetup_ns = 30,
        .DataHold_ns = 25,
        .AddressSetup_ns = 20,
        .SampleDelay_cyc = 0,
parisseb commented 1 year ago

Does it mean that while flashing osloader, the boot block number is also written somewhere on the 39gii ? How does it work for the HP firmware osloader? You mentionned there are 3 copies of the firmware written on the flash, how does the calculator know which one should be used?

Repeerc commented 1 year ago

The STMP3770 includes 64KB on-chip ROM which contains intitialization code written by SigmaTel and can load programs from NAND, sdcard (SSP,SPI), IIC, USB...

Remove all batteries, holding the "ON/C" and plug in USB then use the SBLoader tool can communicate with the ROM Code for uploading the sb firmware to RAM to run. Thus, I don't think it can be bricked...

When boot form the flash, the ROM codes will search three special blocks: NCB(NAND Config Block) ,LDLB(Logical Drive Layout Block), and DBBT(Discovered Bad Block Table). The NCB described the NAND Information like Timing, Page size, blocks... Before found the NCB, the ROM codes will use normal timing and commands to access the flash. https://github.com/ExistOS-Team/ExistOS-For-HP39GII/blob/main/OSLoader/Include/stmp_NandControlBlock.h#L7-L43

The LDLB described the layouts of firmware and data area: https://github.com/ExistOS-Team/ExistOS-For-HP39GII/blob/main/OSLoader/Include/stmp_NandControlBlock.h#L45-L82 In LDLB there are two fields to write the firmware position, when the firmware checksum fail, it will boot another firmware. The firmware was directly wrote SB format file into flash. NCB and LDLB can place in arbitrary block before firmware blocks and have 2 copies for backup in general.

There are a region configuration in HP firmware: flashsdklayout

It seems that the ROM codes just read the LDLB, when firmware boot fail, ROM codes will try to boot firmware 2 and notice the SDK to fix firmware 1 by referring the region configuration.

DBBT used in SigmaTel SDK and the ROM Code doesn't care it.

Here is the HP firmware Flash dump: FlashDump.zip

parisseb commented 1 year ago

Thanks for the details. I'm however afraid I'm still lost. Let me summarize what I understand and please correct if I'm wrong: 1 block=128K=64 pages of size 2K HP firmwares are at block 22, 71 and 120, each of size 49128K=6.272M. This information is written somewhere in the first block of the flash (in a block with an index between 0 to 21). OSLoader is only using block 22. This corresponds to the "page 1408" option of ExistOS updater where 1408=2264. Now what happens if I change this option? I guess, I can only select a multiple of 64, like e.g. 1920(=3064). Is the choice restricted to 7164 and 120*64? I guess not. But then does ExistOS updater write a specific block before block 22 to reflect the change? Thanks!