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

Can't flash firmware #8

Closed
jusubbi opened this issue Sep 23, 2020 · 24 comments
Closed

Can't flash firmware #8

jusubbi opened this issue Sep 23, 2020 · 24 comments

Comments

@jusubbi
Copy link

jusubbi commented Sep 23, 2020

I tried with keul uvision5 and st-link software. Keul gives error about missing packet (i installed GD32F130 package). St-link detect chip as some st version and start to flash it, but stops at beginning. I can disable read out protection.

Do i have to install some button to put chip in programmin mode like mainboard (must hold power button while flashing)?

@EFeru
Copy link
Owner

EFeru commented Sep 23, 2020

For sideboard, you don't need to press any button, just make sure the MCU gets power, either via the ST link or mainboard. I prefer to shut down the mainboard and have power only from ST link during programming.
Can you make a picture of you sideboard?

Usually locking unlocking the chip twice helps in solving the issue.
Also in another thread was mentioned that GD sometimes lie about the flash memory size. So there is a chance that even that your chip supposed to have the datasheet flash size it can be that it has lower.

@jusubbi
Copy link
Author

jusubbi commented Sep 23, 2020

I'm using just sideboard without connection to mainboard and power comes from st-link.
Also locking / unlocking gives error, but still doing it?
Here is pictures from board and errors:

https://photos.app.goo.gl/91fUEPshA6DXv26W6

@EFeru
Copy link
Owner

EFeru commented Sep 23, 2020

Looks exactly as my board.
Does the project in Keil compile without errors? And can you flash via Keil?

Edit: Also in my case I cannot flash via ST Link utility, it gives me an error. I haven't tried yet with Cube MX programmer, maybe that one works.

Flashing via Keil or Platformio should work. Most recently I use more Platfomio because is nicer.

@jusubbi
Copy link
Author

jusubbi commented Sep 24, 2020

Keil compile works without errors, but flash doesn't.

image

image

Platformio build works without error, but upload doesn't

Processing VARIANT_HOVERBOARD (platform: ststm32; board: gd32f130c6; framework: spl)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/gd32f130c6.html
PLATFORM: ST STM32 (8.1.0) > Generic GD32F130C6T6
HARDWARE: GD32F130C6T6 72MHz, 4KB RAM, 32KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES:

  • framework-spl 2.10201.0 (1.2.1)
  • tool-dfuutil 1.9.200310
  • tool-openocd 2.1000.200630 (10.0)
  • tool-stm32duino 1.0.2
  • toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
    Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies...
    No dependencies
    Building in release mode
    Warning! '-Wl,-T' option for specifying linker scripts is deprecated. Please use 'board_build.ldscript' option in your 'platformio.ini' file.
    Checking size .pio\build\VARIANT_HOVERBOARD\firmware.elf
    Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
    RAM: [==== ] 36.0% (used 1476 bytes from 4096 bytes)
    Flash: [======= ] 72.2% (used 23652 bytes from 32768 bytes)
    Configuring upload protocol...
    AVAILABLE: blackmagic, jlink, mbed, stlink
    CURRENT: upload_protocol = stlink
    Uploading .pio\build\VARIANT_HOVERBOARD\firmware.elf
    xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-09:29)
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    debug_level: 1

hla_swd
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080042dc msp: 0x20001000
** Programming Started **
Error: timed out while waiting for target halted
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0x080011d6 msp: 0x20000fe0
Error: error waiting for target flash write algorithm
Error: error writing to flash at address 0x08000000 at offset 0x00000000
embedded:startup.tcl:521: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 586
at file "embedded:startup.tcl", line 521
*** [upload] Error 1
================================================================================================== [FAILED] Took 12.73 seconds ==================================================================================================

Also Cube MX fails:

image

@jusubbi
Copy link
Author

jusubbi commented Sep 24, 2020

I guess these are fake chips. I flashed demo firmware (1288 bytes) and everything goes fine.

image

Then i tried bigger file (10208 bytes) and it fails again.

image

@EFeru
Copy link
Owner

EFeru commented Sep 24, 2020

Wow. Then what is the real size of flash? 8 kB :-o

Can it be that the starting address is not the same? That would be strange.

@jusubbi
Copy link
Author

jusubbi commented Sep 25, 2020

Is there way to check out real flash size? I changed address to 0x07007000 and now it flash it, but it's a mess (or should it look like this?). I don't need IMU or leds, just those 2 sensors working as buttons, so is it possible to reduce firmware size to make it work with these faulty chips?

image

Chips has some blue marking, maybe factory marks defective chips?

image

Original program is only 1kb

image

With cube programmer i managed to flash it partially:

image

@Candas1
Copy link
Collaborator

Candas1 commented Oct 4, 2020

If you need only buttons there is an option to use right sensor cable on the mainboard with buttons. Wouldn't it be good enough? https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/2890745fbb5879b52821231b53c217f886344f4b/Inc/config.h#L250

@EFeru
Copy link
Owner

EFeru commented Oct 4, 2020

Can you update the firmware of your ST Link v2 programmer to the last version? For me it flashes and I remember I did than. I haven't tried before, with the shipped ST link v2 firmware.

See here how to do it:
https://youtu.be/QXbw82Jdtw8

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

If you need only buttons there is an option to use right sensor cable on the mainboard with buttons. Wouldn't it be good enough? https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/2890745fbb5879b52821231b53c217f886344f4b/Inc/config.h#L250

Yes, that be enought. I just really need to know how to connect buttons. Are they between rx/tx or rx/tx to ground?

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

Can you update the firmware of your ST Link v2 programmer to the last version? For me it flashes and I remember I did than. I haven't tried before, with the shipped ST link v2 firmware.

See here how to do it:
https://youtu.be/QXbw82Jdtw8

I have latest version V2.J34.S7

@Candas1
Copy link
Collaborator

Candas1 commented Oct 4, 2020

If you need only buttons there is an option to use right sensor cable on the mainboard with buttons. Wouldn't it be good enough? https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/2890745fbb5879b52821231b53c217f886344f4b/Inc/config.h#L250

Yes, that be enought. I just really need to know how to connect buttons. Are they between rx/tx or rx/tx to ground?

I think it should be connected to 3.3v. Which variant are you using? Want do you want to do with the buttons?

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

If you need only buttons there is an option to use right sensor cable on the mainboard with buttons. Wouldn't it be good enough? https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/2890745fbb5879b52821231b53c217f886344f4b/Inc/config.h#L250

Yes, that be enought. I just really need to know how to connect buttons. Are they between rx/tx or rx/tx to ground?

I think it should be connected to 3.3v. Which variant are you using? Want do you want to do with the buttons?

so right sideboard tx to 3.3v is button1? and rx to 3.3v is button2?

I'm using hovercar variant, so i want use 1 button for phase advance on/off and 2 to change motor driving mode.

@Candas1
Copy link
Collaborator

Candas1 commented Oct 4, 2020

Yes.
This is not yet possible out of the box, but I have it on my to-do list.
Do you want to implement it?
You would have to copy this https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/2890745fbb5879b52821231b53c217f886344f4b/Src/util.c#L1184
And use button1 and button2 variables as input instead. It could be run after read_command function in main loop.

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

I'm not a programmer, so i don't know where i have to copy those lines? I'm better with hardware.

So util.c lines 1184-1242 to main.c between line 203-204 ?

If this is too hard, i think is better for me to just compile firmware with different settings until i found best combination.

Now i have "stock" variant_hovercar with just calibrated ADC values and battery + field weakening enabled.

@Candas1
Copy link
Collaborator

Candas1 commented Oct 4, 2020

OK forget about it then.
Regarding sideboard, if code size is the problem and you only need buttons, you can deactivate mpu sensor here
https://github.com/EmanuelFeru/hoverboard-sideboard-hack-GD/blob/423126eab5739a976c11d7179601a56c5a8f3d52/Inc/config.h#L45

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

OK forget about it then.
Regarding sideboard, if code size is the problem and you only need buttons, you can deactivate mpu sensor here
https://github.com/EmanuelFeru/hoverboard-sideboard-hack-GD/blob/423126eab5739a976c11d7179601a56c5a8f3d52/Inc/config.h#L45

I guess that firmware size is the problem. If i just comment that line 45 does it reduce file size?

@Candas1
Copy link
Collaborator

Candas1 commented Oct 4, 2020

Yes it should

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

Still too large file :( i can flash 2kt to this chip. Now this new file with 6050 disabled is 6kt

@Candas1
Copy link
Collaborator

Candas1 commented Oct 4, 2020

2k seems really low
https://github.com/EmanuelFeru/hoverboard-sideboard-hack-GD/blob/423126eab5739a976c11d7179601a56c5a8f3d52/GD32F130C6T_FLASH.ld#L21
This mcu is supposed to have 32k of flash
Do you have same concern with the other sideboard?

@jusubbi
Copy link
Author

jusubbi commented Oct 4, 2020

2k seems really low
https://github.com/EmanuelFeru/hoverboard-sideboard-hack-GD/blob/423126eab5739a976c11d7179601a56c5a8f3d52/GD32F130C6T_FLASH.ld#L21

This mcu is supposed to have 32k of flash
Do you have same concern with the other sideboard?

Yes i know. Same problem with another sideboard too.

Heap size is 0x200 on this. In here is 0x400?

https://github.com/EmanuelFeru/hoverboard-sideboard-hack-GD/blob/master/MDK-ARM/startup_gd32f1x0.s

@jusubbi
Copy link
Author

jusubbi commented Oct 6, 2020

I now tested those BLDC control types with flashing modified firmware to mainboard and only working type in my use is FOC TORQUE. Also field weakening tested and i don't wanna use it, because my vehicle goes too fast (so it illegal to drive) and use 100% more power just to speed up +33%. So this issue can be closed.

@redeemarr
Copy link

I've had the same issues with sideboard gd32f130c6t6 chip: st-link utility fails to flash relatively big files.
However st-flash worked flawlessly (I used windows binaries). And st-link utility was able to read flashed data. Seems like those 'broken' chips are not so broken.
I haven't tested it yet, though.

@AlfreddGco
Copy link

@redeemarr you are amazing! That just made it work and finally got to upload all the firmware to the chip. Thank you! I have seen several forums with this exact issue, will try to share your answer!

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

5 participants