Electronics > Microcontrollers
STM8: SWIM not working at all
Arisotura:
Hello there!
I might not be posting this in the right place -- if so, sorry about it.
I am working on a personal project that involves the Wii U gamepad -- basically, making custom firmware and homebrew for it.
The Wii U gamepad employs a microcontroller called UIC, which is a STM8. According to the information I have gathered about it, it would be a STM8L151R8 -- 64KB of FLASH, 4KB of RAM, 2KB of EEPROM, LQFP64 package. The UIC chip on the gamepad motherboard has custom markings ("UIC-WUP") but the pinout matches that of a 'stock' STM8L151R8.
Anyway, I have a gamepad motherboard where the UIC was accidentally bricked.
The UIC has a small bootloader at 0x8000, and the actual firmware (which handles input, power management, and other misc. stuff) is installed at 0x9000. The bootloader simply checks a couple bytes in EEPROM for specific values: if these are set, it jumps to the firmware entry point, otherwise it enters firmware upload mode and waits for a firmware binary to be uploaded. The firmware also has a command that triggers firmware upload mode, to allow for updates.
That's the skinny. What happened to me is that corrupted firmware code was uploaded to the UIC, making it impossible to upload new code the normal way. Thus, the UIC is bricked.
This is where I had the idea of using the SWIM interface to unbrick the UIC. In theory, I would just have to clear the 'firmware installed' marker bytes in EEPROM so I could upload new firmware code. Or maybe I would have to reflash the entire thing, but I have dumps of all the data.
Thing is, I can't get the SWIM interface to respond at all.
From the understanding I have gathered, the memories inside the chip might be locked, but the SWIM interface should atleast respond to activation.
But not even.
My last attempt involved programming a FPGA to send the SWIM entry pulses, and seeing what I get on the scope. In theory, after I send the entry pulses, I should receive a sync pulse after a given amount of time, but I don't receive anything. The STM8 is just not responding at all.
I tried with a pull-up resistor on the SWIM pin, but that made no difference.
I ordered a proper STLink so we'll see if that works, but I don't have a lot of faith there.
So, this has me wondering: can the STM8 (in particular the STM8L151R8) have SWIM completely disabled, to the point it doesn't respond at all? From my understanding of the documentation, that isn't the case, but at this point, I'm doubting... what else could the problem be?
Postal2:
--- Quote from: Arisotura on November 08, 2024, 04:03:37 pm ---.... So, this has me wondering: can the STM8 (in particular the STM8L151R8) have SWIM completely disabled, to the point it doesn't respond at all? ....
--- End quote ---
Yes.
--- Quote from: Arisotura on November 08, 2024, 04:03:37 pm ---..... From my understanding of the documentation, that isn't the case, ....
--- End quote ---
This is described in the documentation, I am currently reading it. I can clarify and give an exact quote if necessary.
Arisotura:
From my understanding, SWIM is disabled by writing to a specific register -- and by pulling NRST low, you can enter SWIM before such a register write happens.
Maybe I'm missing something? I'd like a clarification.
Postal2:
--- Quote from: Arisotura on November 08, 2024, 04:32:16 pm ---... Maybe I'm missing something? I'd like a clarification.
--- End quote ---
--- Quote ---Single wire interface module (SWIM) and debug module (DM) RM0016
58/467 DocID14587 Rev 14
There are two important considerations to highlight for the devices where the NRST pin is
not present:
• If the SWIM pin should be used with the I/O pin functionality, it is recommended to add
a ~5 seconds delay in the firmware before changing the functionality on the pin with
SWIM functions. This action allows the user to set the device into SWIM mode after the
device power on and to be able to reprogram the device. If the pin with SWIM
functionality is set to I/O mode immediately after the device reset, the device is unable
to connect through the SWIM interface and it will be locked forever (if the NRST pin is
not available on the package). This initial delay can be removed in the final (locked)
code.
• Their program memory must contain a valid program loop. If the device's memory is
empty, the program continues into non-existing memory space and executes invalid
opcode; this causes the device to reset (reading of non-existing memory is random
content). This behavior might lead to periodic device resets and to a difficulty to
connect to the device through the SWIM interface.
--- End quote ---
https://www.st.com/resource/en/reference_manual/cd00190271-stm8s-series-and-stm8af-series-8bit-microcontrollers-stmicroelectronics.pdf
Arisotura:
That's the thing though, my device does have a NRST pin.
NRST can be disabled, but that's done from STM8 code afaik -- and I'm not seeing any code for that here...
Navigation
[0] Message Index
[#] Next page
Go to full version