-
-
Notifications
You must be signed in to change notification settings - Fork 772
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
Support for STM32WB55xx #458
Conversation
Probably you have a CPU marked "ES". I will try out the PR beginning next week and report back, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change.
Thanks.
The MCU is under a metal shield, I don't intend to desolder it...
…On Fri, Mar 8, 2019, 10:54 UweBonnes ***@***.***> wrote:
Probably you have a CPU marked "ES". I will try out the PR beginning next
week and report back,
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#458 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQ_SzlHLVnJay8wn1W68te5Mrqy_Cjliks5vUjNHgaJpZM4bkYT8>
.
|
The metal shield, is plugged, at least on my parts. Look again. |
My Nucleo kit arrived today, so I've had the opportunity to test this now.
Other observations:
|
Thanks @UweBonnes and @zyp for your comments and info! Code comments:
Ok, this is also as expected, in this light I'll remove all the strictly sample dependent stuff (I'll just keep it for my use), including the CPU2options command.
The L4 itself has different page sizes, and I agree with the proposal (I'm changing the code now). Thanks.
I think I have many, some is formatting (I don't like to see hex numbers with a mix of upper and lower case), and some is more substantial (option handling). The page erase function is just missing a "static", so as to be accessible from other targets Other:
The metal shield is, in fact, removable. No label on mine, though.
Yes, I'll check my boards, but I suspect I haven't got it. But I can freely load everywhere in flash (ESE == 0). |
Perhaps one "no-code change only cleanup commit" and one commit introducing the new feature. I think that works out clearest what changed. But no hard rules on that, only a proposal. What about putting and exporting the page erase function in command.c? |
I second putting cosmetic changes in a separate commit, makes the revision history easier to browse later. A PR can contain more than one commit, so even if you split up unrelated changes, you can still submit them all at once. Today I tried the command for editing option bytes and couldn't get it to write anything, so either I'm not understanding how to use it correctly or it doesn't work properly. Poking at the flash registers directly to make the same changes worked, so it's not that I'm not permitted to make them. I also just had to try turning off the security to see if it was possible, and have apparently bricked the device harder than I expected to. The aforementioned full chip erase apparently went through and the ESE bit at 0x1fff8000 reads 0, but the ESE bit in FLASH_OPTR remains at 1 and everything else still appears locked. Since I still can't read the top area of the flash, I can't say for sure whether I erased it, but STM32CubeProgrammer doesn't manage to connect to FUS anymore. In other words, I've now got a device where I apparently lost the ability to load the encrypted firmware binaries, and I still didn't gain the ability to load my own code for CPU2. I don't recommend attempting the same. :) |
Option bits and register only get into sync after a RESET. Did you issue a reset? B.t.w. what are FUS/RSS you talk about ? Fuses? Relative Signal strength? |
Yes, I've tried both the traditional power on reset and the OBL_LAUNCH bit in FLASH_CR. I can change other stuff in the same register like RDP just fine and have it take effect, but FLASH_OPTR.ESE reads as 1 no matter what. RSS and FUS are respectively Root Security Services and Firmware Update Service. Like I wrote in my first comment it's a preinstalled firmware stored at the top 40k of the flash, responsible for loading and decrypting the encrypted CPU2 firmware binaries. |
Sorry for tedious question: Di you change FSD? And perhaps: Do you have a Stlink with original firmware? Can STM32CubeProgrammer perhaps help you? |
I tried setting FSD but FLASH_SFR still appears to be locked. Anyway, I'm not worried about recovering the device. I went into this fully expecting to lose the ability to load encrypted firmwares, I was just hoping to get the ability to run my own code on CPU2 in return. :) |
So it seems that what was described as a silicon bug in ES, is still there but as some kind of protection? I'll split the commit as suggested. What's the preference for the erase page command? I'll check the options code. |
I did not have much time to work on this as I am abroad (but I brought the Nucleo).
|
4f63303
to
c6e15d6
Compare
Split in 3 commits:
This has been tested only with a WB55 Nucleo:
|
src/target/stm32l4.c
Outdated
#include "target_internal.h" | ||
#include "cortexm.h" | ||
|
||
static bool stm32l4_cmd_erase_mass(target *t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded shuffling around unchanged code.
\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I had moved that without noticing and forgot to reset the position, no reason to do that.
src/target/stm32l4.c
Outdated
@@ -109,19 +114,20 @@ static int stm32l4_flash_write(struct target_flash *f, | |||
#define OR_DBANK (1 << 22) | |||
|
|||
#define DBGMCU_CR(dbgmcureg) (dbgmcureg + 0x04) | |||
#define DBGMCU_CR_DBG_SLEEP (0x1U << 0U) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But...they are misaligned, why keep them that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style versus functional change
Ferderico, sorry if I am picky. You still have unrelated and whitespace changes. git log --check also shows whitespace errors. Otherwise thanks for your persistance so long. |
It's your duty and privilege to be picky, and for me an opportunity to learn (first time I contribute to a real project). |
I only commented some places, so look around for more issues. |
A command to erase one or more pages in flash in command.c. To use it, include command.h and add monitor_cmd_erase_page to the target command list.
Better error handling in option command. Erase page cmd integrated. Changes in the info structure for coming WB55 support.
The support is implemented completely in stm32l4.c. Major changes are related to the different flash controller address, and some special handling for options.
c6e15d6
to
6f86839
Compare
I see and know the difference, of course. Anyhow, if the policy is not to have this kind of edits, I'm reverting them. |
Hah! You won't get rid of me so easily. |
IMO any improvements should be acceptable. The only argument against style changes is that it increases the number of edited lines that has to be reviewed. I'd say just put them in their own commit bundled in the same PR so the style and the functional changes can be reviewed separately. A style only commit is easy to review to check that it's actually only style changes. If you use a Git GUI with line by line staging (e.g. sourcetree/gitx/gitg/etc…) it's a fairly easy process to turn a bunch of changes into a neatly grouped set of commits. At work I often create like five-six commits at a time because I've been making edits all over the place and while it made sense to work on them at the same time, they are independent enough they should be reviewed separately. |
Newbrain, can you resolve the conflicts? |
Possibly in about 15 days, currently out in the mountains with no
computer...and no real internet.
…On Fri, Jul 19, 2019, 14:27 UweBonnes ***@***.***> wrote:
Newbrain, can you resolve the conflicts?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#458>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEH5FTSV4TOVXYJ74HFSFXDQAGXMZANCNFSM4G4RQT6A>
.
|
Please try with #507. Please also look at the comments around the flash region command. |
Is this still planned to go ahead at any time? I may need to work with WB55 soon-ish. Would love to use BMP for that if possible. |
As you hopefully know, BMP is a community effort. What about following the steps from https://tighten.co/blog/adding-commits-to-a-pull-request and cloning newbrain:STM32WBsupport and test and report back? And best rebase to master to update the PR. |
@UweBonnes, sure, I will see if I can repeat the same. I think I was just mostly checking with PR author here to see if he is still interested in completing his contribution here. |
@akamensky If you're just looking for something to use, the PR as it is is working. Just check it out and build it. |
I would appreciated a rebase PR. |
I am trying to rebase the PR on my fork, however I don't think I understand code well enough to resolve a conflict in UPD: There are conflicts all over in Moreover I am not sure why this even had to be added in |
- Stripped down from erase_page - G4 option handling probably missing.
You can try |
I must apologize for not taking care of this myself (after more or less promising I'd do). Thanks once again for your excellent work. |
- Stripped down from erase_page - G4 option handling probably missing.
- Stripped down from erase_page - G4 option handling probably missing.
What is the status on this PR? I see it is currently conflicting HEAD so it would need to be at least rebased? What needs to be still done on this? |
Thank you very much @zyp! :) |
Here is the STM32WB support promised long ago...
What is done:
Slightly changed behaviour (saner, IMO):
With no parameters, print the options words. With
erase
resets them to defaults. Withwrite
only the provided words are written in the options, the remaining ones are left untouched instead of being read and rewritten.monitor erase_page <address> [number of pages]
it is written to be independent of the MCU, it relies only on info from the flash data structure, see discussion at STM32WB support #457
What is not there - and probably cannot be easily implemented (some docs are still not available):
This is a largish commit: though the structure was prepared in #456, still the changes are spread all over, mostly due to the need of parametrize the flash controller base register.