Programming 'F407 ...

Working libraries, libraries being ported and related hardware
User avatar
luudee
Posts: 17
Joined: Sat Oct 08, 2016 4:27 pm
Location: Pattaya
Contact:

Programming 'F407 ...

Post by luudee » Sat Oct 08, 2016 7:02 pm

Hi Guys !

So I have one of those tiny 'F407VET boards. (actually I have a few of them)

I do all my work on Linux, particularly I use Fedora Core 22 at the moment.

I have written a simple sketch to make some LEDs blink ...

Now, I am trying to figure out how to program this baby. I used F103 parts
before, and it was trivial through the built-in serial boot loader.

With the 'F407 things appear much more complex ... :P

First I tried St-Link. I can upload the sketch and it will run properly blinking
the LEDs. And I can read it back and it appears to be the same file as I upload.

BUT, once I hit reset or power cycle this board, my sketch does not run
anymore. I know Boot0 and Boot1 have to be both zero for it to run from Flash,
and I have tried all combinations of the two, nothing. It does not run my sketch.
I can upload it again (setting boot0 to 1), and then it will run again as long as I
don't reset/power cycle the board.

So, next I thought lets get the built in boot loader to work. Took me a while to learn
about DFU ...

I installed all DFU tools, all looks good. I plug in the board (boot0=1), and lsusb shows:
Bus 003 Device 036: ID 0483:df11 STMicroelectronics STM Device in DFU Mode

Looks good, right ?

I than run "dfu-util -a 0 -s 0x08000000 -D test.bin", and I get
"File downloaded successfully".

Than I use "dfu-util -a 0 -Z 17276 -U check.bin" and verify the upload really went fine.

And the files do match. All looks good.

BUT, with DFE it appears my sketch never gets executed.

I have tried various options when uploading my sketch, but no luck. I can power cycle
the board and read my sketch back, it's all there, it's all good.

Why does it not execute my sketch ? I used objdump to disassemble the file (test.bin).
The vector table is there, as expected, all the start-up code is there, and my test code.

Somehow the 'F407 hates me :(

Any ideas suggestions ?

Oh, yeah, I am using the latest DFE utilities, v0.9.

And I get no errors or warnings whatsoever ... so must be operator error ?

Somebody, please help ! :-)

Many Thanks !
rudi


% dfu-util -l
dfu-util 0.9


Found DFU: [0483:df11] ver=2200, devnum=37, cfg=1, intf=0, path="3-13.3.4.3", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="386333563233"
Found DFU: [0483:df11] ver=2200, devnum=37, cfg=1, intf=0, path="3-13.3.4.3", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="386333563233"
Found DFU: [0483:df11] ver=2200, devnum=37, cfg=1, intf=0, path="3-13.3.4.3", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="386333563233"
Found DFU: [0483:df11] ver=2200, devnum=37, cfg=1, intf=0, path="3-13.3.4.3", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="386333563233"

User avatar
RogerClark
Posts: 7445
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Programming 'F407 ...

Post by RogerClark » Sat Oct 08, 2016 9:59 pm

Strange

I had a similar issue on a F103 "Ugly board"

It would work fine directly after upload via USB to Serial

but not after reboot

The only think I could think of, which may cause this, was faulty oscillator startup

But I tried changing the code to stop and restart the oscillator after a timeout, and it didnt fix the problem

Normally STLink uploads work well

So its strange if you can read back from 0x800000 and the binary is fine but it won't run after a power cycle.
Did you read back after power cycling to check the program is still in flash ?

Are you sure its in flash not ram ? (this seem unlikely with STLink, but is possible with Serial upload)

Did you try using GDB (SOrry not sure how to connect GDB to STLInk as I use BMP)

User avatar
luudee
Posts: 17
Joined: Sat Oct 08, 2016 4:27 pm
Location: Pattaya
Contact:

Re: Programming 'F407 ...

Post by luudee » Sun Oct 09, 2016 8:25 am

Thanks for the quick reply Roger !
Did you read back after power cycling to check the program is still in flash ?
Yes I did, and the comparison passed.
Are you sure its in flash not ram ? (this seem unlikely with STLink, but is possible with Serial upload)
Well, I guess this is really impossible to know, lol

If I go by the address, I am writing and reading 0x08000000 - and this should be flash

The only other thing that comes to m mind, is that the startup/initialization (in my file) is not working properly.

When I use st-link, it somehow configures the device correctly, but than if I try to run my code stand alone, the init fails ...

I'll have to look into this more.

Thanks,
rudi

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Programming 'F407 ...

Post by stevestrong » Sun Oct 09, 2016 9:11 am

Do you try to execute the program after reset when STLink is still connected?
I mean I read somewhere that the STLInk adapter will block the execution, dunno why...

User avatar
luudee
Posts: 17
Joined: Sat Oct 08, 2016 4:27 pm
Location: Pattaya
Contact:

Re: Programming 'F407 ...

Post by luudee » Sun Oct 09, 2016 4:00 pm

Hi Steve,

when I program with St-Link, my sketch DOES run ! My LEDs are flashing !

But, once I hit reset/power cycle, it will not run again.

I tried all combination of boot switches as well.

Only right after programming the sketch it will run, and will run for hours if I don't disturb it.

If I turn off the board, set both boot switches to zero, and power the board back up again (not through st-link),
my sketch does NOT to run ...

Setting Boot0 to 1 and programming through st-link again, will get it working again !

Wery strange ! :P

Thanks,
rudi

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Programming 'F407 ...

Post by stevestrong » Sun Oct 09, 2016 5:49 pm

Do you disconnect the STLink wires (both data and clock) from the board when trying to run standalone?

User avatar
luudee
Posts: 17
Joined: Sat Oct 08, 2016 4:27 pm
Location: Pattaya
Contact:

Re: Programming 'F407 ...

Post by luudee » Sun Oct 09, 2016 5:58 pm

Hi Steve,

yeah, I tried that. Still nothing ...

But that shouldn't make a difference. In "normal" boot mode, when both boot0
and boot1 are 0, the device should work as normal.

I am not=w giving up the libs of Tilen, and will try my luck with Koduino !

Thanks,
rudi

User avatar
RogerClark
Posts: 7445
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Programming 'F407 ...

Post by RogerClark » Sun Oct 09, 2016 8:21 pm

Rudi

You could try using STMs non Arduino tools e.g. STM32CubeMx, and download the free version of Atollic True Studio

The Cube is a big program and a bit daunting to get the clocks setup correct, but it does export a True Studio project file ( and Keil etc) , so you could try that instead.

Or, I think OpenOCD supports debugging via STLink, so you may be able to connect after a cold boot and get GDB to tell you the Program Counter addresss e.g. see where its stuck.

If you can splash out in $2 STM32F103C8 board, you could flash the Blackmagic probe firmware onto it, and use GDB directly and issue commands etc, to see whats going on.

Or, can you try uploading via USB to serial instead?

BTW. Are you sure your program is in Flash and not RAM?

edogaldo
Posts: 284
Joined: Fri Jun 03, 2016 8:19 am

Re: Programming 'F407 ...

Post by edogaldo » Mon Oct 10, 2016 6:53 am

Hi Rudy, you said you have few f407 boards, correct? Does the problem happen with all of them?

User avatar
luudee
Posts: 17
Joined: Sat Oct 08, 2016 4:27 pm
Location: Pattaya
Contact:

Re: Programming 'F407 ...

Post by luudee » Mon Oct 10, 2016 10:19 am

Hi Guys,

Thanks for all the messages !

So I made a bit progress ! The Koduino library was surprisingly easy to set
up and use.

Edoglando, funny you should ask ! Out of the 10 boards I have, 4 seem
not to like the programming and do not execute my test sketch. The other
6 appear to work.

Now, I have 6 blinking boards and 4 "dead" ones. The dead ones are quite
interesting, and I wonder if it is a programming "bug" or "feature". I can
program the Flash, and read back, even after power cycling, BUT, it does
not execute my simple blinking sketch. I have also been trying to force the
use of HSI, instead of HSE to avoid external crystal issues. Not sure if that
has propagated now or not, or even if it will become effective when using
dfu, or I must use st-link.

I ideas guys ? Sound like a strange issue, and 4 boards having the same
issue, is also strange ...

BTW, destroyed a second st-link adapter last night. What's wrong with these
things, ? Looks like the LDO is dead, if powered by external battery it seems
to work :/

Many Thanks,
rudi

Post Reply