BETA bootloader for Generic boards . Already working.

Bootloader for boards that don't have the addition hardware found on the Maple mini, which resets the USB
victor_pv
Posts: 1070
Joined: Mon Apr 27, 2015 12:12 pm

Re: BETA bootloader for Generic boards . Already working.

Postby victor_pv » Thu May 21, 2015 3:10 pm

The code is a bit messy at places.
When I compared it to the updated maple mini code, the RET6 code had many mistakes that had been corrected over the years in some basic stuff, so I corrected all that, but still in general my guess is that this was a work in progress that leaf labs never finished.

It looks like several pieces where glued together to make it work, with the intention of later cleaning it up to make it consistent, but never got to that point.
I am a complete beginner and still spotted strange stuff, I'm sure we are seeing loads of things that look strange.

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

Re: BETA bootloader for Generic boards . Already working.

Postby RogerClark » Thu May 21, 2015 8:36 pm

Victor

Can you remember what other code appeared to contain redundant or bad code?

It's possible the Maple mini branch that I took my original code from, doesnt have those issues, because it looks like all the branches got updated separately. Hence why I want to unify it for the future ;-)

Edit. BTW. I'm not sure if its worth updating, but I've noticed that the usb_lib that is used by the bootloader, dates back to 2008 !!!!!!

I'm pretty sure I've see a newer version kicking around on the web (from STM)

One of the reasons to update would be to get rid of all those annoying compile warnings. I personally don't like warnings as they often mask potential bugs.

So if I get chance I may replace the lib_usb with an up to date one.

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

Re: BETA bootloader for Generic boards . Already working.

Postby RogerClark » Fri May 22, 2015 2:06 am

Victor

Just a quick update.

I've done a bit more tidying and have cut down the amount of config that is required, so that you only have to set the port and the pin for the LED and the button

But....

For some reason, I can't use all pins on the Maple mini as the LED.

I don't seem to be able to use PA15 or PA14 or PA13, however I can use PC13
Initially I thought I must have stuffed up the masking and bit shifting of the control register setup, or the gpio_write_bit etc

But, as now after various bits of tinkering, I can use PC13 as the LED, I don't think there can be anything wrong with my code

So, looking at the manual for the chip (that huge PDF), it looks like the reason that I can't use PA14 or PA15 is because the spec has the "Main function" of these pins as JTAG pins.

So I think we need to do some AFRemap stuff in order to make these pins available

I guess it depends if we want to debug the bootloader via STLink or BMP etc, I guess we may want to do that.

But perhaps this could be a #define for ENABLE_SWD and normally have it turned off.

Otherwise people will end up doing what I've been doing, which is spend loads of time thinking they've wired stuff up incorrectly ;-)

Edit. I just tried disabling the SWD and JTAG but have not really had any success

Perhaps I've missed something. I thought that I just need to change the

AF remap and debug I/O configuration register (AFIO_MAPR)
Address offset: 0x04

Bits 26:24 SWJ_CFG[2:0]: Serial wire JTAG configuration
These bits are write-only (when read, the value is undefined). They are used to configure the
SWJ and trace alternate function I/Os. The SWJ (Serial Wire JTAG) supports JTAG or SWD
access to the Cortex® debug port. The default state after reset is SWJ ON without trace.
This allows JTAG or SW mode to be enabled by sending a specific sequence on the JTMS /
JTCK pin.
000: Full SWJ (JTAG-DP + SW-DP): Reset State
001: Full SWJ (JTAG-DP + SW-DP) but without NJTRST
010: JTAG-DP Disabled and SW-DP Enabled
100: JTAG-DP Disabled and SW-DP Disabled


But unfortunatly this has not enabled PA13 etc, so perhaps I need to do something else, as well as this. But looking at what the maple mini does in the code to disable or enable the SWD its basically the same code

victor_pv
Posts: 1070
Joined: Mon Apr 27, 2015 12:12 pm

Re: BETA bootloader for Generic boards . Already working.

Postby victor_pv » Fri May 22, 2015 4:00 pm

Interesting, it never occurred to me that some ports would be set to default for JTAG.

I think there are two options then, remap the pins, or just write a warning with your finding in the code section that manages the PIN, indicating X Y and Z pins can not be used for leds because they are used for JTAG.

If you think we really need to be able to use all pins, I can check the datasheet later to see if I find any missing step.

victor_pv
Posts: 1070
Joined: Mon Apr 27, 2015 12:12 pm

Re: BETA bootloader for Generic boards . Already working.

Postby victor_pv » Sun May 24, 2015 4:05 pm

As part of testing the USB port yesterday, I changed modes in the PA12 before and after the pull down, to see if there would be other results.
I set to output OD after the pull, set it to input pullup, and also tested on setting it to output OD rather that PUPD before the pull down.
It worked all the time, but I did notice more consistent reenumeration if I set the pin to Output OpenDrain rather than PullUp/PullDown before pulling it low.
May be just perception because I was messing so much with it trying to make sure it didn't break... resets, power down, reset again and again...
But at the moment I will keep it with Output OpenDrain rather than PU/PD for a while and see how it goes.

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

Re: BETA bootloader for Generic boards . Already working.

Postby RogerClark » Sun May 24, 2015 9:54 pm

Thanks victor

I think the thing we need to do is test on multiple hosts, e.g not just windows, so will see if I can test on OSX

Btw. I have been continuing to tidy up the bootloader code, so that the config.h is a lot less complex.

Once I have tested on a few more boards I will push the code

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

Re: BETA bootloader for Generic boards . Already working.

Postby RogerClark » Wed May 27, 2015 4:32 am

Victor,

I can't find any reference online where the DBGMCU_IDCODE can be read by by the processor its self.

I found this on a russian website (google translate http://translate.google.com.au/translat ... rev=search )

Where they stated it could not be read in normal mode, even though the manual says it can.

But as we know the manual is not always right, hence the Application Notes and Erratica, but I really cant find anything useful about this.

Anyway, at the moment it looks like we still need to set the flash page size in the config for the bootloader :0(

Edit.

I found out its not possible to read this value

See

http://www.st.com/st-web-ui/static/acti ... 190234.pdf

2.3 Debug registers cannot be read by user software


:-(

victor_pv
Posts: 1070
Joined: Mon Apr 27, 2015 12:12 pm

Re: BETA bootloader for Generic boards . Already working.

Postby victor_pv » Wed May 27, 2015 3:00 pm

Great :(

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

Re: BETA bootloader for Generic boards . Already working.

Postby RogerClark » Wed May 27, 2015 8:46 pm

We may still be able to infer page size based on total flash size, but I'm not that hopeful

User avatar
ahull
Posts: 1422
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: BETA bootloader for Generic boards . Already working.

Postby ahull » Wed May 27, 2015 10:42 pm

Is there anything non unique about the "unique identifier" or some other register(s) possibly in the memory controller (FSMC) that would allow you to identify or infer page size?
- Andy Hull -


Return to “Generic bootloader”

Who is online

Users browsing this forum: No registered users and 1 guest