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

Add support for STM32L412 #754

Closed
jcw opened this issue Dec 27, 2018 · 6 comments · Fixed by #799
Closed

Add support for STM32L412 #754

jcw opened this issue Dec 27, 2018 · 6 comments · Fixed by #799

Comments

@jcw
Copy link

jcw commented Dec 27, 2018

I've made the following changes to stlink to get it to recognise and upload to the L412:

$ git diff
diff --git a/src/chipid.c b/src/chipid.c
index 6f93af1..ca6e815 100644
--- a/src/chipid.c
+++ b/src/chipid.c
@@ -507,6 +507,19 @@ static const struct stlink_chipid_params devices[] = {
             .bootrom_base = 0x1ff00000,
             .bootrom_size = 0x2000
         },
+        {
+            // STM32L41X
+            .chip_id = STLINK_CHIPID_STM32_L41X,
+            .description = "L412 device",
+            .flash_type = STLINK_FLASH_TYPE_L4,
+            .flash_size_reg = 0x1fff75e0,    // "Flash size data register" (sec 49.2, page 1809)
+            .flash_pagesize = 0x800,         // Page erase (2 Kbyte) (sec 3.2, page 93)
+            // SRAM1 is 32k at 0x20000000
+            // SRAM2 is 8k at 0x20008000
+            .sram_size = 0x0A000,
+            .bootrom_base = 0x1fff0000,
+            .bootrom_size = 0x7000
+        },
         {
             // unknown
             .chip_id = STLINK_CHIPID_UNKNOWN,
diff --git a/src/flash_loader.c b/src/flash_loader.c
index 7684680..f2e6367 100644
--- a/src/flash_loader.c
+++ b/src/flash_loader.c
@@ -306,6 +306,7 @@ int stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t*
         loader_code = loader_code_stm32f0;
         loader_size = sizeof(loader_code_stm32f0);
     } else if ((sl->chip_id == STLINK_CHIPID_STM32_L4) ||
+              (sl->chip_id == STLINK_CHIPID_STM32_L41X) ||
               (sl->chip_id == STLINK_CHIPID_STM32_L43X) ||
               (sl->chip_id == STLINK_CHIPID_STM32_L46X) ||
               (sl->chip_id == STLINK_CHIPID_STM32_L4RX) ||

I'm not sure about bootrom_size, but the rest should be correct.

Note also that STLINK_CHIPID_STM32_L41X (0x464) was already present in src/chipid.h.

@xor-gate
Copy link
Member

Please provide a PR (https://help.github.com/articles/about-pull-requests/)

@xor-gate xor-gate closed this as completed Feb 2, 2019
@stlink-org stlink-org deleted a comment from jcw Feb 2, 2019
@stlink-org stlink-org deleted a comment from jcw Feb 2, 2019
@xor-gate xor-gate reopened this Feb 2, 2019
@xor-gate xor-gate changed the title Here's how to add support for STM32L412 Add support for STM32L412 Feb 2, 2019
@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Feb 15, 2019
@EliKrumholz
Copy link
Contributor

I implemented a similar change without seeing this first and ended up with all the same values as @jcw, and it appears to be working fine with the NUCLEO-L412KB board. @xor-gate Can I open up a pull request (EliKrumholz@348149b), or were there any other issues that needed to be addressed?

@lukebayes
Copy link

lukebayes commented Feb 10, 2020

I'm struggling to get st-link to work on an STM32L412x chip and stumbled over this thread. I got excited and thought maybe this change was never integrated, but alas, it was.

For future readers, the change(s) suggested by @jcw & @EliKrumholz above was merged in May of 2019.

Thanks!

@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 added this to To do in Release v1.6.1 via automation Feb 21, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, v1.6.1 Feb 21, 2020
@Nightwalker-87 Nightwalker-87 self-assigned this Feb 21, 2020
@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Feb 21, 2020

Please verify if the issue still exists in Release v1.6.0.

@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.1, Feedback required Feb 21, 2020
@lukebayes
Copy link

I can confirm, that I was able to get STLINK to upload directly to two different STM32L412xx chips using both FTDI and SWD without any changes to software.

@Nightwalker-87
Copy link
Member

Fixed since commit 189f253 which is part of Release v1.6.0.

Release v1.6.1 automation moved this from To do to Done Feb 21, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: Feedback required, v1.6.1 Feb 21, 2020
@Nightwalker-87 Nightwalker-87 removed this from Done in Release v1.6.1 Feb 21, 2020
@Nightwalker-87 Nightwalker-87 removed this from the v1.6.1 milestone Feb 21, 2020
@Nightwalker-87 Nightwalker-87 added this to the v1.6.0 milestone Feb 21, 2020
@Nightwalker-87 Nightwalker-87 linked a pull request Mar 20, 2020 that will close this issue
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants