Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ability to enable isp flash #1

Open
mightymos opened this issue Jan 8, 2023 · 0 comments
Open

No ability to enable isp flash #1

mightymos opened this issue Jan 8, 2023 · 0 comments

Comments

@mightymos
Copy link
Owner

Hi Jonathan,

I've run into the same problems as you, and it took me some time to understand why.
The explanation was on page 277 of the STC15 family documentation, under section 3.1 (Program Memory).
It explains there are 3 sections in the chip's flash:

  • AP: where the application program resides
  • IAP: EEPROM emulation for persistent data storage
  • ISP: reserved space for a custom bootloader

As IAP and ISP are often used together ("IAP/ISP") throughout the documentation, I've confused them.

Section 3.1 says that in order to use the ISP area, the "ISP data flash" must be enabled, but I couldn't find how to enable it.

Section 2.2.8 (Warm Boot and Cold Boot Reset) on page 242 explains that failure to find valid ISP code causes an automatic software reboot to AP.
This explains why nothing happened, the program was caught in an infinite reset loop.

I've also tried to jump directly from the AP to the EEPROM start address with an inline LJMP instruction but it didn't work either.
The portion reserved to the EEPROM is probably flagged as non-executable, so we're in the "Reset caused by illegal use of program address" case of the table in section 2.2.8.

Incidentally, while I was examining STCGAL's debug logs, I found the size written always exceeds the number of 512-byte flash pages by 64 bytes.
These are used by the MCU options and are always written after the code + EEPROM content.
This is why options can't be changed independently from the code.

What a waste to have such a large EEPROM space and not enough Flash storage for the software to use it! :(
There's just one thing you can do with the EEPROM space, it's storing constants (e.g. strings, look-up tables).
This has been found to work and is explained here: zerog2k/stc_diyclock#6 (comment)
Mind the last 7 bytes of the AP area are used to store a chip UID, so you have to tell it to SDCC.

Vincent Defert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant