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

v30x blink example don't run if TARGET_MCU_PACKAGE sets to CH32V307VCT6 #303

Open
romainreignier opened this issue Apr 13, 2024 · 6 comments

Comments

@romainreignier
Copy link

Hi,
First, I would like to thank you for this amazing project.
I have successfully tried the blink example from the examples_v30x on a CH32V307 EVT by SCDZ board.
But the board is actually populated with a CH32V307VCT6 and the Makefile selects a CH32V305RBT6, I have then replaced it with the following:

all : flash

TARGET:=blink
TARGET_MCU:=CH32V307
TARGET_MCU_PACKAGE:=CH32V307VCT6

include ../../ch32v003fun/ch32v003fun.mk

flash : cv_flash
clean : cv_clean

And after a make clean and then make, the code does not run once uploaded to the board.

I have also tried with the debugprintfdemo copied from the V003 examples, it works with the V305RBT6 settings but not with the V307VCT6.

From the ch32v003fun.mk, the difference is only the MCU_PACKAGE and the sizes for the FLASH and RAM.

I have then tried to configure TARGET_MCU_PACKAGE:=CH32V307RBT6 and in that case, the code runs.

When it does not work, I have tried to use GDB and adding a breakpoint on the first line of the main on the SystemInit() line. The breakpoint is reached but on first step, I am in the DefaultIRQHandler.

Does anyone have a clue of why I have this behavior when using the config matching my MCU?

@cnlohr
Copy link
Owner

cnlohr commented Apr 22, 2024

Sadly, at the moment no one is looking into this specific target. If you are up for seeing where we've made a mistake, it would be great to let us know.

There's plarform-specific code in the .ld, Makefile, and ch32v003.h

As a note, when changing the .ld, you will need to remove the auto-generated .ld for your part in the ch32v003fun folder.

Please let us know what you find.

@romainreignier
Copy link
Author

When setting TARGET_MCU_PACKAGE:=CH32V307VCT6, if I only change manually the generated_CH32V307VCT6.ld file with the following:

--- generated_CH32V307VCT6.ld.orig      2024-04-24 14:54:05.818278697 +0200
+++ generated_CH32V307VCT6.ld   2024-04-24 14:54:15.906340380 +0200
@@ -1,8 +1,8 @@
 ENTRY( InterruptVector )
 MEMORY
 {
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
-  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
+  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
+  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
 }
 SECTIONS
 {

It works.
Reading the datasheet, I have noted this footnote but I could not find (or more exactly, don't know where to find) more info about this:
image

@cnlohr
Copy link
Owner

cnlohr commented Apr 24, 2024

@AlexanderMandera - do you recall if you ever tested with CH32V307VCxx? Should this line read 2 instead of 1? MCU_PACKAGE:=1 https://github.com/cnlohr/ch32v003fun/blob/6c3c515598db6d3d50f8087da2f694ee417fc445/ch32v003fun/ch32v003fun.mk#L114C14-L114C18

@romainreignier Can you test with changing that line of that file from 2 to 1, removing the generated .ld file, and seeing if it works then?

@romainreignier
Copy link
Author

If I change the 1 to a 2, it works but the linker script now contains 128K of flash and 32K of ram while according to the datasheet, the VC variant should be 256/64:
image

@cnlohr
Copy link
Owner

cnlohr commented Apr 27, 2024

I am just not familiar with the 30x line, does it make sense to add another package type for the 307? You can copy-paste it from one of the other parts, and make a PR.

@bmx
Copy link
Contributor

bmx commented May 11, 2024

make TARGET_MCU=CH32V307 TARGET_MCU_PACKAGE=CH32V307VCT6

it should work

MEMORY
{
  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
}

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

3 participants