NEED HELP.. STM32F103C8T6 can’t BOOT as normal

Jackson009
Fri Aug 07, 2015 3:52 pm
Hi Everyone,
This is my 1st post in this board. So far i have fun with This. STM32duino so much.
I have done my project for RFID logger

> RFID RC522 reader / SPI 2
> SD card / SPI 1
> LCD12864 ST7920 / SW SPI
> DS1302 / SW I2C

Slowly from beginning all the things work. Untill my code size go up to 45kB / 8kB RAM.
Then i try to make board Run by 5V AC adaptor.
Board can not run / BUT it can run only after i Download code from Serial(from IDE). Then run.
It can not run by itself.

I try with other code. Blink / Serial.. ALL work as normal(by 5V AC adaptor).
Pls help Did i miss out something?

Thanks,
Jackson009


RogerClark
Fri Aug 07, 2015 9:02 pm
Are you using the Ugly board.

Some of these seem to have some sort of startup issues.

My Ugly board does the same, and one other person has the same issue, but 2 other people have Ugly boards that are fine.

At the moment we do not have a work around for the Ugly board issue, as it seems to be some sort of hardware design fault in the reset circuit on that board.


Jackson009
Sat Aug 08, 2015 2:02 am
I am using the other one. It is RED color.
1.) They use R = 22k at BOOT1 , BOOT0
2.) Other code working fine. I have another project with GPS size 54kB is Ok.

I am checking by tak out Lib. One by one from my code. I suspected that the RTC use VirtualWire(I2C). Cause a problem.

Thanks.


RogerClark
Sat Aug 08, 2015 4:22 am
Can you post a link to the board?

We have problems with this board.

Image

Some boards (mine included) will not boot and run the code, they only work if the code is uploaded via STLink or USB to Serial and then the code is run after upload.

The code does not seem to run from cold boot :-(

The problem seemed to be limited to some boards like this, but perhaps your board also has the same problem.


Jackson009
Sat Aug 08, 2015 5:00 am
This is my board which from China cost 4USD.
There is only BOOT0 for jumper.

STM32

http://m.intl.taobao.com/detail/detail. … 3163102087

GD32

http://m.intl.taobao.com/detail/detail. … 3196369961

This one got 2 version STM32F103 and GD32F103(108Mhz) . Same PCB.


RogerClark
Sat Aug 08, 2015 6:55 am
Both boards look the same to me.

I’ve not seen a GD32F103, Unless its entire functionality e.g. control register addresses and usage etc, are exactly the same as the STM32F103 then Arduino_STM32 won’t run on it.

The STM32F103 can be made to run at above 72Mhz, but its beyond its technical specification, and the USB won’t work at any speeds other then 72Mhz and 48Mhz because of the USB clock divider register only has 2 possible values, Divide by 1 or Divide by 1.5 as the USB bus operates at 48Mhz

I suppose they may have set their divider to 2.25 for speeds of 108 Mhz, or it could be a completely different MPU

I’d be interested to know if either of these boards work. The STM32 is most likely to work, the GD32F103 probably won’t work, but may work if its a clone of the STM32.

Can you find a programming manual for the GD32 device. I found GD’s website, http://www.gigadevice.com/product-category/11.html
But I can’t find a programming manual for the processor, which details its operation down to the register addresses and the bits inside each register.


Jackson009
Sat Aug 08, 2015 8:04 am
Roger,
Well,, i have both of them for 2 each. GD32 price is look good in commercial.
I am working in STM32 board.
But actually i had spend a time to make GD32 run by modify the board.txt(and so on).
Well, by changing the F_CPU to 108000000, It’s work!!! but i can make it run only Serial.print(“Hello”);
The I/O and peripheral i think it is different pin map of address i think. Yes, i download it as the same my STM32 board(Serial).
After that, i give up… since spend too much time on it. And look like a hard work on GD32.

Seller GD32 said.. pin to pin compatible /108MHz with 0 Wait state accessing memory. Which sounds GREAT! to me.

Thanks,


RogerClark
Sat Aug 08, 2015 8:23 am
GD32 sounds very interesting

Does the USB work??

Please post more information if you have it, I’m sure everyone would be interested in a $4 that goes at 108Mhz !!!


Jackson009
Sat Aug 08, 2015 9:12 am
I am not testing the USB yet. :lol:
P/N: exactly STM32 Clone.
GD32F103C8T6 etc.

I found the problem with my code. Due to i have problem with I2C. So far i am not success with Using I2C. on Wire.h
GLCD12864 LCD – I2C still not even work.
Then i found this DS1302 from virtuabotix. It is work fine with I2C port.

virtuabotixRTC myRTC(PB7,PB6,PB5);

I think above may cause problem while booting. I try to move to other pin.. But RTC is giving wrong data.

I use this and seems to use SW I2C for communicate.

https://www.virtuabotix.com/virtuabotix … ing-guide/

This code. with PB7,PB6,PB5 can run after load firmware by Serial. But Can’t run by itself with external 5V.
I am still find out to to make it work.
If anyone got DS1302 working code. Pls advise me.

Thanks,


ahull
Sat Aug 08, 2015 10:03 am
WOW… I’ve just compared theGD32F103xx datasheets memory map with the STM32F103x8/B datasheets.

They appear to be very nearly identical, with the GDM device having more peripherals.
Is the GD device licensed from STM perhaps? Or is it just a very close copy I wonder… It does seem to be almost identical in every respect. I would suspect that code compiled for a STM32F103XX variant would have a pretty good chance of running on the comparable GD device.


RogerClark
Sat Aug 08, 2015 10:26 am
Hi Andy

It definitely looks very interesting.

But I can’t find any boards for sale on either eBay or AliExpress


ahull
Sat Aug 08, 2015 1:03 pm
I’ve not found any boards for sale yet, but this article looks interesting. It seems the Gigadevice chip is in fact a derivative clone rather than a direct copy.

There are some compatibility issues, however for most purposes the Gigadevices chip looks to be compatible (especially if you stick to 72MHz clock speeds). Now all we need is for some enterprising individual to start flogging them in a place where we can actually get a sample, and we may have a new contender for the cheapest ARM Arduino compatible in the world. I suspect we would need to call it a GD32duino however (or a genetically modified STM32duino perhaps the GMduino :twisted: )


Jackson009
Sat Aug 08, 2015 3:06 pm
It does drop in replacement. It very popular in China.
If you have Keil compiler. It should competible in code.
GD even come out the same Dev. Tool like STM nucleo.
Biggest Flash size 3M is something impressive.
Soon you can find GD on Ebay store. :)

RogerClark
Sat Aug 08, 2015 10:11 pm
I will see what the price works out to be, if buying 5 via a buying agent from Taubao

Looking on Taubao, it looks like a lot of vendors list boards as GD32f103 , STM32f103 so they view them as interchangeable, but this could just be physical pin compatibility, rather than identical software compatibility.

If nothing else, this will put downward price pressure on STM


Jackson009
Sun Aug 09, 2015 3:43 am
Roger/Andy,
Look like i may use GD in STM32DUINO sooner.
I have a Chinease friend can buy those for me. If you like i can get the to send over to you.

Thanks,
Jackson009


RogerClark
Sun Aug 09, 2015 4:25 am
I have a Chinease friend can buy those for me. If you like i can get the to send over to you.

Thanks.

I’m not sure if is cheaper just to buy though a Taubao agent?

I think the agents get special / cheap postage.

I know @victor_pv has bought some boards via an agent (I can’t remember which agent). I want to try buying though an agent so that I know what the process is.

With the price of these boards, the majority of the cost is going to be the postage.

So its probably best to buy at least 2 or perhaps 5 boards

However I’m not sure how compatible they are to lib maple

@jackson009

Can you tell us how you have made it work?

Have you uploaded via USB to Serial ? I think you said Serial.print works ? Or perhaps only blink ?

Thanks


Jackson009
Sun Aug 09, 2015 7:36 am
Roger,
Board look exactly same. I load firmware and the same i did in STM by FTDI(Serial).
> Serial.print(“HELLO TEST”);
> BLink.

Above are Work with GD32F103C8T6 by change F_CPU in board.txt from 72000000 to 108000000

Thanks,


RogerClark
Sun Aug 09, 2015 8:13 am
Sounds excellent

Did you try to load the STM22duino bootloader

https://github.com/rogerclarkmelbourne/ … bootloader

The generic bootloader to use is the one to match the LED position e.g. PC13 would be

https://github.com/rogerclarkmelbourne/ … 0_pc13.bin

Or for all the others that I have already built see

https://github.com/rogerclarkmelbourne/ … 1/binaries

If you can’t find one to match your LED it doesn’t matter, it still works, but its better if you can see the LED flashing to show the bootloader is working

You can flash the bootloader using USB to Serial etc


Jackson009
Sun Aug 09, 2015 10:38 am
Hi,
My code is now working. Problem from DS1302 lib.
It stuct in func. While call Struct data.
I put it all to main code. And call struct data in majn loop. The code work with external 5v now.

GD32, I have just started STMDUINO for 2weeks.
I do not have ST-Link to flash USB boot loader yet.
I will try other code ex. Blink and Timer etc.
ST-Link is on the way. Soon i can use USB download now.

Thanks,


RogerClark
Sun Aug 09, 2015 11:09 am
You can flash the bootloader using USB to Serial on PA9 and PA10, with Boot0 = HIGH

Use stm32flash.exe on windows (or similar program on linux and osx)

e.g. if your com port for USB to serial is COM10

open a command window to tools/win in the Arduino_STM32 folder and then use

stm32flash.exe -g 0x8000000 -b 230400 -w FULL_PATH_TO_BOOTLOADER_BIN_FILE COM10


Jackson009
Sun Aug 09, 2015 12:02 pm
Roger,
Thanks. I will try soon. I have check again.
I just only change. Following in stm32.h

\IDE\hardware\Arduino_STM32\STM32F1\system\libmaple\stm32f1\include\series

#if STM32_F1_LINE == STM32_F1_LINE_PERFORMANCE
# ifndef STM32_PCLK1
# define STM32_PCLK1 36000000U
# endif
# ifndef STM32_PCLK2
# define STM32_PCLK2 108000000U // << from 72000000
# endif
# ifndef STM32_DELAY_US_MULT
# define STM32_DELAY_US_MULT 12 /* FIXME: value is

Then Serial.print can work as preferred speed. Blink I/O still OK.

digitalWrite(PC13,!digitalRead(PC13)); Work on GD32

———————————————————————————————————-

#define LED_PIN PC13
#define BUTTON_PIN PB12
#define LED_RATE 500000 // in microseconds; should give 0.5Hz toggles

void handler_led(void);
void handler_count1(void);
void handler_count2(void);

int toggle = 0;
int count1 = 0;
int count2 = 0;

void setup()
{
Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor
// Set up the LED to blink
pinMode(LED_PIN, OUTPUT);

// Set up BUT for input
pinMode(BUTTON_PIN, INPUT_PULLUP);

// Setup LED Timer
Timer2.setChannel1Mode(TIMER_OUTPUTCOMPARE);
Timer2.setPeriod(LED_RATE); // in microseconds
Timer2.setCompare1(1); // overflow might be small
Timer2.attachCompare1Interrupt(handler_led);
// Timer2.resume();

// Setup Counting Timers
Timer3.setChannel1Mode(TIMER_OUTPUTCOMPARE);
Timer4.setChannel1Mode(TIMER_OUTPUTCOMPARE);
Timer3.pause();
Timer4.pause();
Timer3.setCount(0);
Timer4.setCount(0);
Timer3.setOverflow(30000);
Timer4.setOverflow(30000);
Timer3.setCompare1(1000); // somewhere in the middle
Timer4.setCompare1(1000);
Timer3.attachCompare1Interrupt(handler1);
Timer4.attachCompare1Interrupt(handler2);
Timer3.resume();
Timer4.resume();

}

void loop() {

// Display the running counts
Serial.print(“Count 1: “);
Serial.print(count1);
Serial.print(“\t\tCount 2: “);
Serial.println(count2);

// Run… while BUT is held, pause Count2
for(int i = 0; i<1000; i++) {
if(digitalRead(BUTTON_PIN)) {
// Timer4.pause();
} else {
// Timer4.resume();
}
delay(1);
}
}

void handler_led(void) {
toggle ^= 1;
digitalWrite(LED_PIN, toggle);
}

void handler1(void) {
count1++;
}
void handler2(void) {
count2++;

}
———————- OUT PUT 115200bps ——————-
Count 1: 164896 Count 2: 164899
Count 1: 165504 Count 2: 165507
Count 1: 166113 Count 2: 166116
Count 1: 166722 Count 2: 166725
Count 1: 167331 Count 2: 167333
Count 1: 167939 Count 2: 167942
Count 1: 168548 Count 2: 168551
Count 1: 169157 Count 2: 169160
Count 1: 169765 Count 2: 169768
Count 1: 170374 Count 2: 170377

——————————————————————

I use my CODE which use in STM32F103C8T6 compile to GD32F103C8T6
Working portion
> LCD ST7920 ( SW SPI )
> USART
> DS1302 ( SW I2C )
Not – Working
> RFID ( HW SPI2 )
> SD CARD ( HW SPI1)

I think i need to configure in SPI.h or something. For the speed or some register which miss match.


ahull
Sun Aug 09, 2015 3:39 pm
Hi Jackson009 I’m not sure that this change will have the effect you expect.

The PLL Multiplier will need to change from x9 (8 MhZ x 9 = 72MHz) to x11 (8 MHz x 11 = 108 MHz) and I’m not sure that changing “# define STM32_PCLK2 108000000U // << from 72000000 ” is all that is necessary to run the core at 108 MHz and still keep the other peripherals in step.

Unfortunately I’m not up to speed with the code that sets the various clocks – they are defined in system/libmaple/stm32f1/include/series/rcc.h but exactly how, or indeed if STM32_PCLK2 108000000U translates to a pll multiplier of x11 I don’t know. However I made the change you mentioned above, and so far as I can see my STM32F103R8T6 is still running at 72 MHz (unfortunately ‘cos I was rather hoping to be able to push the thing a little harder).
Also as Roger pointed out, the USB clock seems to be defined relative to the the pll clock as PLLCLK_1Div5 or PLLCLK_Div1, so setting the PLL multipler may break USB (and then again it may not :D experiments trump speculation every time).

Edit: Suggestion…. it might also be worth moving or changing this thread to reflect the fact that we are dealing with a non STM chip and attempting over clocking to boot. My befuddles brain would then find the thread easier to locate in the future :D


martinayotte
Sun Aug 09, 2015 5:00 pm
The PLL settings code in F4 I’m used to is quite different than the one under F1.
But I think I’ve discovered where things happened :

In the variant, the BOARD_RCC_PLLMUL is clearly defined as RCC_PLLMUL_9 for the MapleMini.
It is located in Arduino_STM32/STM32F1/variants/maple_mini/wirish/boards_setup.cpp

By creating a new GD32 variant, it will be easy to define the BOARD_RCC_PLLMUL to RCC_PLLMUL_11.


RogerClark
Sun Aug 09, 2015 9:23 pm
If you change the main Pll multipler, the usb may stop working, as the usb divider is set to 1.5 in the existing code.

But perhaps the same bit pattern on the USB divder gives the necessary divider ratio, when the clock is at 108 mhz, to still have the USB clock at 48 mhz.

And.. Yes. duplicate the generic_st32f103c folder and rename it, then copy the section of coce in boards,txt related to the stm32f103c and replace all the text in the copy of the section with gd32f103c (except the MCU setting, which you will need to leave on STM32xxxx for the moment as its used in the core)

in the longer term…

Dependig on the number of changes, we may just be able to add a few ifdef’s to the core etc
To support this board…

I guess i better order some today ;-)


RogerClark
Sun Aug 09, 2015 11:29 pm
Re: SPI

Test on the STm32F103 first.

Getting SD to work is not that easy even on STM32F103, the problem may not be with the GD32F103

Re: Buying some boards from china

I looked at the cost of agents, and their shipping charges were very high. Minimum was around $15 (USD) for a single item, possibly $20 (USD) for 5 items because of the weight.

I think this is not really the cost of postage, but is he cost to process the purchase, but its a bit too high for me, as you’d need to buy 10 boards to bring the shipping cost down to a reasonable percentage of the cost.

e.g. I think I can send a small package overseas for around $5 not $15. (albeit that doesn’t factor in my time, but if I was doing hundreds of parcels a day, the you could easily make a decent living out of it)


victor_pv
Mon Aug 10, 2015 1:31 am
RogerClark wrote:I will see what the price works out to be, if buying 5 via a buying agent from Taubao

Looking on Taubao, it looks like a lot of vendors list boards as GD32f103 , STM32f103 so they view them as interchangeable, but this could just be physical pin compatibility, rather than identical software compatibility.

If nothing else, this will put downward price pressure on STM


RogerClark
Mon Aug 10, 2015 1:44 am
Hi Victor.

The prices on Taobao are very good, but the shipping / handingly costs seem high for small items (at least though the shipping agent’s I’ve looked at)

I’m getting quoted prices of about $15 to $20 USD minimum handling / shipping costs, which is a lot of a $2.50 item.

I think @Jackson009 said that he had a contact / friend in China who may be able to buy and them post onwards.

And I recall there is someone else on the forum who lives in China, but I can’t recall who that was, as they have said in the past, that they may be willing to buy things on behalf of the forum and post them onwards.

A maple mini board only weights about 4.5grammes, so even including the pins, I suspect the total weight of those boards is only around 10 to 15 grammes, and can be sent in a normal padded envelope as a letter


Jackson009
Mon Aug 10, 2015 2:42 pm
Sorry come late. I am not sure we have to re-do PLL or not.

STM32 Board use > 8MHz Crystal PLL = 9 / 9×8 – 72M
GD32 Board use > 12MHz Crystal PLL = 9 / 9×12 – 108M

Actually i can try with changing Crystal from 12 to 8 in GD32. So that we can see if it is a Drop-in Replacement?

Regarding on buy item from Taobao.

Example : 10RMB
Shipment cost(in China) : 8RMB

So that when item get to Chinese friend. So, Register mail is 3-4USD for small package item.
The difficult part is some of them do not have Paypal(3%charge). For my case i transfer them in “RMB”.
If not many items pls send me a list and yr address. :)

Let me do another post in other Board(non-STM) Topic so that you can easy to find next time.


victor_pv
Mon Aug 10, 2015 2:53 pm
RogerClark wrote:Hi Victor.

The prices on Taobao are very good, but the shipping / handingly costs seem high for small items (at least though the shipping agent’s I’ve looked at)

I’m getting quoted prices of about $15 to $20 USD minimum handling / shipping costs, which is a lot of a $2.50 item.

I think @Jackson009 said that he had a contact / friend in China who may be able to buy and them post onwards.

And I recall there is someone else on the forum who lives in China, but I can’t recall who that was, as they have said in the past, that they may be willing to buy things on behalf of the forum and post them onwards.

A maple mini board only weights about 4.5grammes, so even including the pins, I suspect the total weight of those boards is only around 10 to 15 grammes, and can be sent in a normal padded envelope as a letter


RogerClark
Mon Aug 10, 2015 9:15 pm
Thanks Victor,

It wasn’t clear when I looked at Yoybuy prices, that just forwarding was an option.

I will take another look.


ahull
Tue Aug 11, 2015 12:30 am
Jackson009 wrote:S
STM32 Board use > 8MHz Crystal PLL = 9 / 9×8 – 72M
GD32 Board use > 12MHz Crystal PLL = 9 / 9×12 – 108M

RogerClark
Tue Aug 11, 2015 12:45 am
Guys,

I’ve ordered some from Yoybuy, however its the first time I have ordered through them, so at the moment the order is just showing as waiting to be processed.
I have ordered several, so will probably have some that I don’t need. However, with the cost of processing, they will be more expensive than the Red Pill etc.

I’m sure I’ve read quite a long list of small differences between the STM32 and the GD32.

The key thing IMHO will be the USB divider, as if that can’t be configured to operate the 48Mhz USB when the device is operating at 108Mhz then its not going to be very much more than an overclock-able STM32.

Well, I presume its stable at 108Mhz which the ST32 won’t necessarily be.

Did anyone find the equivalent of the programming manual for this device?


martinayotte
Tue Aug 11, 2015 2:22 am
What is appeal me with this board is the flash size.
I presume anything else can be workarounded … (crossing my fingers)
If we can somehow get deals, I’m ready to be part of community purchase …

Jackson009
Tue Aug 11, 2015 10:38 am
Dear ALL,
I have put in new topic.
http://www.stm32duino.com/viewtopic.php?f=44&t=485

I have check again. Now SPI ALL working :)
Just LED blinking too fast. LOL!!!


RogerClark
Tue Aug 11, 2015 9:30 pm
thanks

Leave a Reply

Your email address will not be published. Required fields are marked *