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

v2.3.5 will not flash or work with the new openxenium 1.4 #8

Open
tcirre93 opened this issue Aug 12, 2023 · 4 comments
Open

v2.3.5 will not flash or work with the new openxenium 1.4 #8

tcirre93 opened this issue Aug 12, 2023 · 4 comments

Comments

@tcirre93
Copy link

The new version 1.4 of openxenium was recently released and v2.3.5 can no longer recognize this version when trying to update using the upgrade tool. It recognizes the openxenium but fails to read properly during the flash. I tried a manual flash and it did not work either. Looks like a mismatch somewhere.

@catogtp
Copy link

catogtp commented Aug 17, 2023

Can confirm. I flashed 1.4 cpld code to OX that was using build 2.3.1 of XeniumOS. Run the 2.3.5 updater, it goes through and erases and flashed, but fails when it verifies

@gaasedelen
Copy link

gaasedelen commented Aug 18, 2023

I tested this tonight after cato mentioned this issue and was able to reproduce your problem.

I've reflashed bios' a few dozen times on my Xenium since the updated CPLD a few weeks back, so I was curious what XeniumOS does since it seems able to reliably write to flash just fine:

image

It looks like they specifically try and read-back the byte they just wrote (the while loop) and wait for that to return the correct results. This differs from what this repo, and Xenium-Tools do:

for (uint32_t i = 0; i < sizeof(patch_bootloader); i++) {
xenium_start_flash_program_byte(XENIUM_BANK_BOOTLOADER_OFFSET + i, patch_bootloader[i]);
while(xenium_flash_busy()) { ;; }
}

...

uint8_t xenium_flash_busy(void)
{
return xenium_flash_read_byte(0) != xenium_flash_read_byte(0);
}

I guess, reading back the state of byte 0 does not guarantee the state/availability of all flash sectors?

The fix should ditch the existing busy loop and do something like XeniumOS, instead:

void xenium_start_flash_program_byte(uint32_t address, uint8_t data)
{
    lpc_send_byte(0xAAAA, 0xAA);
    lpc_send_byte(0x5555, 0x55);
    lpc_send_byte(0xAAAA, 0xA0);
    lpc_send_byte(address, data);
    while (xenium_flash_read_byte(address) != data);
}

I tested this on hardware, and it appears to work. I also tested it on even faster chips with less wait states than the recent 1.4 CPLD, so it should be solid fix and seems to make sense:

image

While Xenium-Tools seemed to be able to read and write ok in its current state (its write loop isn't as tight) it's probably best this fix be reflected over there too. I'll probably make PR's to both repos, and maybe fix up a quirk or two while I am at it.

Here's an updated fw-update xbe with the fixes described above, let me know if this works for you: xenium-fw-update.zip

gaasedelen added a commit to gaasedelen/xenium-fw-update that referenced this issue Aug 18, 2023
@tcirre93
Copy link
Author

Can confirm this fix works. Everything works as it should!

@Ryzee119
Copy link
Collaborator

Just saw this issue and was about to add it to xenium tools. Interesting that fixes it though
The datasheet specifically says you can read any address
Toggle Bit I on DQ6 indicates whether an Embedded Program or Erase algorithm is in progress or complete, or whether the device has entered the Erase Suspend mode. Toggle Bit I may be read at any address

The legacy chip has identical wording
Toggle Bit I on DQ6 indicates whether an Embedded Program or Erase algorithm is in progress or complete, or whether the device entered the Erase Suspend mode. Toggle Bit I may be read at any address,

🤷

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

4 participants