aboutsummaryrefslogtreecommitdiff
path: root/src/flash
AgeCommit message (Collapse)AuthorFilesLines
2021-06-04Avoid non-standard conditionals with omitted operands.R. Diez3-7/+7
Fixes bug #257. Change-Id: I05fc6468306d46399e769098e031e7e588798afc Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de> Reviewed-on: http://openocd.zylin.com/6271 Tested-by: jenkins Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-05-29openocd: use macro ARRAY_SIZE()Antonio Borneo2-3/+3
There are still few cases where the macro ARRAY_SIZE() should be used in place of custom code. Use ARRAY_SIZE() whenever possible. Change-Id: Iba0127a02357bc704fe639e08562a4f9aa7011df Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6260 Reviewed-by: Xiang W <wxjstz@126.com> Tested-by: jenkins
2021-05-22flash: fix some minor typoAntonio Borneo6-6/+6
Minor typos found by the new checkpatch boosted by the dictionary provided by 'codespell'. Change-Id: Ia5f134c91beb483fd865df9e4877e0ec3e789478 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6215 Tested-by: jenkins
2021-05-22flash/stm32l4x: add missing break statementTarek BOCHKATI1-1/+3
this is not a bug fix, this for loop will issue only one match adding the break will save unnecessary more loops. Change-Id: Ic1484ea8cdea1b284eb570f9e3e7818e07daf5cd Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/6248 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-05-11flash/nor/xcf: Do not use 'Yoda conditions'Marc Schink1-11/+11
Change-Id: I17308f5237338ce468e5b86289a0634429deaaa9 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6201 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-05-08telnet/auto-complete: hide deprecated and internal commandsAntonio Borneo1-0/+1
For both: - TCL proc that redirect deprecated commands to the new commands, - TCL proc used internally and not supposed to be exposed to user, add their name to the list of commands that should be hide by the telnet auto-complete. Change-Id: I05237c6a79334b7d2b151dfb129fb57b2f40bba6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6195 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-05-02tcl/board: add pico-debug supportPeter Lawrence3-0/+456
pico-debug is not a board; it is a virtual CMSIS-DAP adapter that runs on the same RP2040 also being debugged. This is possible due to pico-debug running on the normally-dormant second Cortex-M0+ core (Core1), providing debugging of the first core (Core0). As such, it could be used on a variety of RP2040-based boards. Since a flash driver is useful (if not essential), a flash driver is included. This driver code originated on RPi's bespoke OpenOCD fork; lipstick was added to this particular pig to make it more presentable on OpenOCD proper. no new Clang analyzer warnings Change-Id: I31f98b5ea1664f0adfbc184b57efba963acfb958 Signed-off-by: Peter Lawrence <majbthrd@gmail.com> Reviewed-on: http://openocd.zylin.com/6075 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-02flash/nor/stm32f1x: Add support for GD32F1x0/3x0asier701-4/+34
Nowadays, when it's difficult to buy STM32F030, the use of GD32F130 seems to be an interesting functional alternative. This is cortex-M3 and it works with the stm32f1x driver, but unfortunately not fully. The main difference is another offset of user option bits (like WDG_SW, nRST_STOP, nRST_STDBY) in option byte register (FLASH_OBR/FMC_OBSTAT 0x4002201C). Any use of functions like lock or unlock results in change default values of the those bits stored in flash. Thus broken microcontroller is malfunctioning, e.g. flash block programming is interrupted by unexpected active hardware watchog (after 0.4s). This patch is a simplified version of #4592 done by Dominik Peklo (http://openocd.zylin.com/#/c/4592/). GigaDevice GD32F1x0 & GD32F3x0 series devices share DEV_ID with STM32F101/2/3 medium-density line, however they use a REV_ID different from any STM32 device, so can be succesfully detected. Change-Id: I252cdf738d94983b70676a3497326f90c329e292 Signed-off-by: asier70Andrzej Sierżęga <asier70@gmail.com> Reviewed-on: http://openocd.zylin.com/6164 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-01Cleanup of config/includes.Tim Newsome2-0/+2
Remove a use of AH_BOTTOM from configure.ac. This macro is used by autoheader to add '#include' of some include file to the end of config.h.in and then to config.h. OpenOCD can be built with a custom config.h, so it's preferable to move these '#include' statement directly in the C files that need them dropping this unneeded dependency. It also causes problems when I want to use the gnulib library (which comes with its own Makefile, and does not have the same include path as the top-level Makefile). So this change touches a lot of files, but is actually really simple. It does not affect functionality at all. Change-Id: I52c70bf15eb2edc1dd10e0fde23b2bcd4caec000 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/6171 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-04-22flash/nor/nrf5: Fix data types and const correctnessMarc Schink1-14/+7
Change-Id: I8c5bac7098d92e9b3bd1b045735879cf32ac218d Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6163 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-04-22flash/nor/numicro: Use 'bool' data typeMarc Schink1-1/+1
Change-Id: Ib4ee64dec9c1253ae45bc58e9f175ab36964180a Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6162 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-04-18helper/command: pass command prefix to command registrationAntonio Borneo3-7/+4
Replace the "struct command *parent" parameter with a string that contains the command prefix. This abstracts the openocd code from the knowledge of the tree of struct command. This also makes unused the function command_find_in_context(), so remove it. Change-Id: I598d60719cfdc1811ee6f6edfff8a116f82c7ed6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5668 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-03-24flash/stm32l4x: probe tzen and rdp valuesTarek BOCHKATI2-11/+60
introduction of 'enum stm32l4_rdp' enumerating possible RDP levels for devices with and without TrustZone. also in 'stm32l4_flash_bank' structure we added and rdp and tzen members to store read values by the helper 'stm32l4_sync_rdp_tzen' these new members are used to display security and protection status while probing the flash. Change-Id: Icf883189715278a3323fe210d295047678b16592 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5541 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-24flash/stm32l4x: introduce stm32l4_part_info.flags for devices featuresTarek BOCHKATI1-39/+33
instead of adding a new member into stm32l4_part_info for every relevant feature, .flags serves as container for the devices' features. identified features: F_HAS_DUAL_BANK, F_USE_ALL_WRPXX, F_HAS_TZ Change-Id: I3093e54c6509dec33043ebe6f87675198bf1967a Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5540 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-24flash/stm32l4x: enhance protect handler to use efficiently all WRP areasTarek BOCHKATI1-56/+386
stm32l4_protect: was using one WRP area per bank, without checking if it is already protecting some sectors. protection algo is more complicated than that, before using a WRP area we should check if it is already used, then either reuse it for extension (or reduction) or use a free area. introduce a new command: stm32l4x wrp_info bank_num ['bank1'|'bank2'] this command lists the protected areas using WRP. Note: for some devices like STM32L4R/S in single bank mode, all 4 WRP areas are usable for that bank, to manage this case an attribute 'use_all_wrpxx' was introduced into stm32l4_part_info and used later in protection handlers example usage: $ telnet localhost 4444 > flash probe 0 device idcode = 0x10036470 (STM32L4R/L4Sxx - Rev: Y) flash size = 2048kbytes flash mode : dual-bank flash 'stm32l4x' found at 0x08000000 > stm32l4x wrp_info 0 no protected areas > flash protect 0 0 4 on set protection for sectors 0 through 4 on flash bank 0 > flash protect 0 8 9 on set protection for sectors 8 through 9 on flash bank 0 > stm32l4x wrp_info 0 protected areas: [0,4][8,9] > flash protect 0 6 6 on the device WRPxy are not enough to set the requested protection failed setting protection for blocks 6 to 6 > flash protect 0 3 5 on set protection for sectors 3 through 5 on flash bank 0 > stm32l4x wrp_info 0 protected areas: [0,5][8,9] > flash protect 0 6 7 on set protection for sectors 6 through 7 on flash bank 0 > stm32l4x wrp_info 0 protected areas: [0,9] > flash protect 0 5 6 off cleared protection for sectors 5 through 6 on flash bank 0 > stm32l4x wrp_info 0 protected areas: [0,4][7,9] Change-Id: I42bd84fa66edd93406e18c6d89310faa5267ffa7 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/6107 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-24stm32l4x: add OTP support for STM32 G0/G4/L4/L4+/L5/WB/WL devicesTarek BOCHKATI1-1/+159
this is a rework of #5320 started by Andreas then abandoned. same syntax as in stm32f2x driver: enable OTP for writing > stm32l4x otp 1 enable write to OTP > flash write_bank 1 foo.bin 0 > flash filld 0x1FFF7000 0xDeadBeafBaadF00d 1 read OTP > mdw 0x1FFF7000 4 disable OTP > stm32l4x otp 1 disable Change-Id: Id7d7c163b35d7a3f406dc200d7e2fc293b0675c2 Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5537 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-24flash/nor/atsame5: add SAME51G18A and SAME51G19A devicesTomas Vanek1-1/+3
Change-Id: Icbb49c76594152e9c5da1c7465675de26c86540e Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reported-by: mikewolak@users.sourceforge.net Fixes: https://sourceforge.net/p/openocd/tickets/288/ Reviewed-on: http://openocd.zylin.com/5984 Tested-by: jenkins
2021-03-24flash/nor/cfi: fix uninitialized write-mem pointerMischa Studer1-9/+5
In flash/nor/cfi.c:835 struct cfi_info is allocated by malloc(). As write-mem was uninitialized the pointer pointed to an out of range address, which led to a segmentation fault and crashed openocd. This happened during flash-command of an external flash-bank, using cfi. Use calloc() instead. While on it check for NULL return and remove unnecessary initialzation. Change-Id: I0e2ffb90559afe7f090837023428dcc06b2e29f6 Signed-off-by: Mischa Studer <mischa.studer@csa.ch> Reviewed-on: http://openocd.zylin.com/6070 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-19build: remove warnings with gcc 11Rene Kita1-3/+3
This removes some warnings which prevent a successful build with -Werror which is enabled by default. I'm using gcc 11, so maybe others are not getting this warnings yet. In src/flash/nor/numicro.c the debug messages were misleadingly indented. In src/target/arm920t.c the array size where smaller than expected from the receiving function. Change-Id: I66f5c6a63beb9f9416e73b726299297476c884d8 Signed-off-by: Rene Kita <git@rkta.de> Reviewed-on: http://openocd.zylin.com/6104 Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-03-19startup.tcl: remove commands already deprecated in v0.7.0Antonio Borneo1-11/+0
Some command were already marked as deprecated in release v0.7.0, more then 7 years ago, and for some of them the depredation date is even earlier. We can reasonably expect that in these 7 years any user of OpenOCD has already migrated to v0.7.0 or to some following intermediate build, thus has already updated any local/personal script to get rid of the deprecated message. Drop the commands already deprecated in v0.7.0. Change-Id: I81cdc415ab855ebf30980ef5199f9780c5d7f932 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6085 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-16flash/stm32l4x: zero init stm32l4_flash_bank struct on flash bank initializationRaúl Sanchez Siles1-1/+1
This is specially needed when, in the probe routine, device is not found among the stm32l4_parts. In this case, the stm32l4_flash_bank->part_info is undefined and inadvertentanly used afterwards: part_info = stm32l4_info->part_info; If the stm32l4_flash_bank is zero init, the probe routine checks for the validity of the part_info field in the previous struct and correctly detects the unsupported (or not found) condition, raising an error rather than a SIGSEGV Change-Id: I7d9d669fb3fa7f8f0903acd60046966b4acb0031 Signed-off-by: Raúl Sánchez Siles <rasasi78@gmail.com> Reviewed-on: http://openocd.zylin.com/6103 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-10flash/nor/stmqspi: Replace macros with static inline functionsMarc Schink1-96/+131
There is no good reason to use macros instead of static inline functions. The current code is hard maintain. For example, it changes variables outside of the macro scope. Also, it is conflicting with the C coding style. Change-Id: I5ac9d2ae076ef73c176d4e32b2e7e0a99fa875ab Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6046 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-03-10flash/nand/lpc32xx: Remove typedef'd structMarc Schink1-10/+10
The C style guide forbids typedef'd structs, see 'Naming Rules'. Change-Id: I983dd52307136d1b5adb58d8c44c0c14422d31e2 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6032 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-01-18flash/stmqspi: fix build error with -Werror=maybe-uninitializedTarek BOCHKATI1-1/+1
using gcc 9.3 on ubuntu focal fossa with -Werror=maybe-uninitialized we get this error: /src/flash/nor/stmqspi.c: In function ‘read_flash_id’: /src/flash/nor/stmqspi.c:1948:6: error: ‘retval’ may be used uninitialized Change-Id: Ifd8ae60df847fc61e22ca100c008e3914c9af79b Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Reviewed-on: http://openocd.zylin.com/6012 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-01-13openocd: fix doxygen parameters of functionsAntonio Borneo5-6/+9
Add to doxygen comment the missing parameters. Remove from doxygen comment any non-existing parameter. Fix the parameter names in doxygen comment to match the one in the function prototype. Where the parameter name in the doxygen description seems better than the one in the code, change the code. Escape the character '<' to prevent doxygen to interpret it as an xml tag. Change-Id: I22da723339ac7d7a7a64ac4c1cc4336e2416c2cc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6002 Tested-by: jenkins
2021-01-13openocd: fix incorrect doxygen commentsAntonio Borneo1-2/+2
Use '@param' in front of function's parameters and '@a' when the parameter is recalled in the description. This fixes doxygen complains: warning: Found unknown command '@buff16' While there, fix a minor typo s/occured/occurred/ in a comment and the typo s/@apram/@param/ in a doxygen comment. Change-Id: I5cd86a80adef552331310a21c55ec5d11354be21 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6001 Tested-by: jenkins
2021-01-13flash/nor/max32xxx: fix path of include fileAntonio Borneo1-1/+1
The relative path should have three times '..'. Issue identified by doxygen: src/flash/nor/max32xxx.c:85: warning: include file ../../contrib/loaders/flash/max32xxx/max32xxx.inc not found, perhaps you forgot to add its directory to INCLUDE_PATH? Change-Id: Ie7b4948c6770b8acb9eff26e08eea32945ebb219 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5997 Tested-by: jenkins
2020-12-26Correct warning messageLuca Lindhorst1-2/+2
The warning message regarding wrong verification checksum for LPC2000, claims that the verification will fail, but the checksum written correctly by openocd. Clarify this in the warning message. Change-Id: I929ac767f7f9fdad9bace250c8c04a776462800a Signed-off-by: Luca Lindhorst <l.lindhorst@wut.de> Reviewed-on: http://openocd.zylin.com/5956 Tested-by: jenkins Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-12-09flash/nor/stmsmi: fix compile error with clang 12.0.0Antonio Borneo1-4/+3
The git preliminarily version of clang 12.0.0_r370171 f067bc3c0ad6 reports an error in the expansion of the macro SMI_READ_REG(): error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro] Remove one intermediate macro expansion to make clang happy. Change-Id: I8ae6d9c18808467ba8044d70cbf0a4f76a18d3e6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5958 Tested-by: jenkins Reviewed-by: Xiaofan <xiaofanc@gmail.com>
2020-12-09flash/nor/sfdp|stmqspi: fix build issue with clang on mac OSTarek BOCHKATI2-15/+15
Change-Id: I3b3aa4236125523ad65fd615ada0f5647d26f526 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5940 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2020-11-15flash/nor/stm32f1x: fix error messageTomas Vanek1-1/+1
Backported from gd32vf103.c Change-Id: I9c5bb7b36e6efcee0473c97047058ef26cc46eb7 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5927 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2020-11-15stm32l4x: cosmetic simplification of get_stm32l4_infoTarek BOCHKATI1-10/+8
Change-Id: I2542f946f64388d908b1502f869643080fce9f9e Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5536 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-15flash/stm32l4x: STM32L55/L56xx basic support (non-secure mode)Tarek BOCHKATI2-12/+64
STM32L5 have 512 Kbytes of Flash memory with dual bank architecture. STM32L5 flash is quite similar to L4 flash, mainly register names and offsets and some bits are changed. NON-SECURE flash is located at 0x8000000 like L4 devices, so no big change is needed (secure flash will be subject of another change). Note: flash driver name is set stm32l5x, in order to extend the commands with specific L5 commands (to manage TZEN for example ...) Note: this works only when TZEN=0 Change-Id: Ie758abb4aa19a3f29eeb0702d7dcb43992e4c639 Signed-off-by: Michael Jung <mijung@gmx.net> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5510 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-15flash/stm32l4x: introduce table with register offsetsTarek BOCHKATI2-49/+104
This change is a preparation for STM32L5 support on top of L4 driver STM32L5 flash is quite similar to L4 flash, mainly register names and offsets and some bits are changed. flash_regs table is introduced within stm32l4_flash_bank struct in order to get correct register offsets, by using the driver internal function 'stm32l4_get_flash_reg_by_index'. To use efficiently register indexes, stm32l4 _[get|read|write]_flash_reg functions are surcharged to accept register indexes. IMPORTANT: stm32l4_write_option is not surcharged, and they always accept the option register offset. tested on NUCLEO-G474RE and STM32L4R9I-DISCO Change-Id: I739d3e97d63b831af6aa569c5629db0000209551 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5509 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-15flash/nor/psoc6: remove setting of xPSR.T bit from sromalgo_prepare()Tomas Vanek1-6/+0
PSoC6 erases flash to 0x00 not more common 0xff, so a device with erased flash loads xPSR.T=0 from the zeroed reset vector. Wrong thumb bit value caused a target algorithm failed with HardFault. The low level write to xPSR solved the problem only if xPSR cached copy was not marked dirty. Later commit 49bd64347a21f5e12b33c256171b3035126d1260 fixed T setting for all Cortex-M target algorithms. Since 49bd64 this part of code is useless as xPSR target_start_algorithm() sets always xPSR dirty so the effect of the low level write is eliminated (and proper setting of thumb bit is ensured in target_start_algorithm()) Change-Id: I68aea5e921fbc6203f2fe91a45f10d22869327de Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5875 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-15cortex_m: use the new enum ARMV7M_REGSEL_nameAntonio Borneo1-1/+1
Register xPSR is indexed directly with its value 16 or with the incorrect enum ARMV7M_xPSR. Replace them with the new enum ARMV7M_REGSEL_xPSR. Change-Id: I86600e7f78e39002ce45f66d4792d5067c1f541b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5873 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-15flash/stmqspi: minor fixes on coding styleAntonio Borneo3-117/+114
Add space around operators; use BIT() macro in place of left shifting constant 1; remove space between cast operator and value; do not check a pointer before free() it; add parenthesis around parameters in macros; fix indentation using only TABs; remove line continuation '\' at code lines out of macros. Change-Id: I809e8ee72d7bfe49d0edf10afb36efe2458de77c Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: e44539d66c89 ("Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface") Reviewed-on: http://openocd.zylin.com/5932 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com>
2020-11-08Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interfaceAndreas Bolsch13-28/+3045
- write speed up to 150 kByte/s on STM32F469I-disco (due to SWD clock and USB connection), up to 1 MByte/s on Nucleo-F767ZI with external STLink-V3 or Nucleo-G474RE with two W25Q256FV in dual 4-line mode or STM32H73BI-Disco in octal mode - tested with STM32L476G-disco (64MBit flash, 3-byte addr), STM32F412G-Disco, STM32F469I-Disco, STM32F746G-Disco, and STM32L476G-Disco (all 128Mbit flash, 3-byte addr), STM32F723E-Disco, STM32F769I-Disco (512Mbit flash, 4-byte addr) STM32L4R9I-Disco, STM32L4P5G-Disco (512MBit octo-flash, DTR, 4-byte addr) STM32H745I-Disco, STM32H747I-Disco (two 512MBit flash, 4-byte addr) STM32H73BI-Disco, STM32H735G-Disco (512MBit octo-flash, DTR, 4-byte addr) - suitable cfg for Discovery boards included - limited parsing of SFDP data if flash device not hardcoded (tested only in single/quad mode as most devices either don't support SFDP at all or have empty(!) SFDP memory) - 'set' command for auto detection override (e. g. for EEPROMs) - 'cmd' command for arbitrary SPI commands (reconfiguration, testing etc.) - makefile for creation of binary loader files - tcl/board/stm32f469discovery.cfg superseded by stm32f469i-disco.cfg - tcl/board/stm32f7discovery.cfg removed as name is ambiguous (superseded by stm32f746g-disco.cfg vs. stm32f769i-disco.cfg) - dual 4-line mode tested on Nucleo-F767ZI, Nucleo-H743ZI and Nucleo-H7A3ZI-Q with two W25Q256FV, and on Nucleo-L496ZP-P and Nucleo-L4R5ZI with two W25Q128FV, sample cfg files included and on STM32H745I-Disco, STM32H747I-Disco, STM32H750B-Disco - read/verify/erase_check uses indirect read mode to work around silicon bug in H7, L4+ and MP1 memory mapped mode (last bytes not readable, accessing last bytes causes debug interface to hang) - octospi supported only in single/dual 1-line, 2-line, 4-line and single 8-line modes, (not in hyper flash mode) Requirements: GPIOs must be initialized appropriately, and SPI flash chip be configured appropriately (1-line ..., QPI, 4-byte addresses ...). This is board/chip specific, cf. included cfg files. The driver infers most parameters from current setting in CR, CCR, ... registers. Change-Id: I54858fbbe8758c3a5fe58812e93f5f39514704f8 Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-on: http://openocd.zylin.com/4321 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Christopher Head <chead@zaber.com>
2020-11-07target/image: Use proper data typesMarc Schink3-9/+9
While at it, fix some coding style issues. Change-Id: Id521394d89e0bf787a6f812701c2cc0fe7e4e63f Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5919 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-04flash: declare local symbols as staticAntonio Borneo9-15/+19
Functions and variables that are not used outside the file should be declared as static. Change-Id: I52d46ed6d4c9b98a7152eb23274c836416f409a3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5893 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-04flash/nor/atsamv: fix clang static analyzer warningTomas Vanek1-0/+3
Warning: line 679, column 4 4th function call argument is an uninitialized value Change-Id: If62d96e1595be945c8e17885bb402e820fb1ec7b Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5903 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
2020-10-28flash/nor/nrf5: unify size of HWIDTomas Vanek1-5/+6
HWID is a part of 32 bit CONFIGID register. hwid member of struct nrf5_info was typed uint32_t to enable direct CONFIGID read and masked afterwards. Change to uint16_t to unify with hwid in struct nrf5_device_spec and RM description. Change-Id: Ib720d3ce23c301aee41d074ea78a6f00a23aed68 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5589 Tested-by: jenkins
2020-10-28flash/nor/nrf5: improve handling of nRF52 flash errorsTomas Vanek1-2/+2
nRF52 devices indicate a flash error by emitting hard fault exception (unlike nRF51 series). Change error message when NVMC READY read fails. A hard fault from flash erase/write operation is detected here. Check exit point of the flash write algo to ensure a failed write is recognised. Change-Id: I637eda268a6bf45f7f41bcb9dcd82db8f5cb41b4 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5587 Tested-by: jenkins
2020-10-28flash/nor/nrf5: check protection before flash erase/write on nRF51Tomas Vanek1-48/+98
nRF51 devices have a clumsy flash protection based on UICR CLENR0. A code running in RAM can write to a protected flash region without any hint the protection gets violated. NVMC flash page erase obeys protection setting but fails absolutely silently. Before this change the first problem was not addressed in the code. To justify the second one, protection was loaded during probe, after protection setting and after a mass erase. Move protection updates to the beginning of erase/write operation and limit them to nRF51 series only. Check for protected sectors before write. The change also fixes the problem of 'nrf5 mass_erase' on nRF52833/840 devices. They use ACL flash protection, which is not supported in nrf5 driver. mass_erase then looked like it failed. Change-Id: Ie58cda68eb104d410b02777c3df5b343408e2666 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5522 Tested-by: jenkins
2020-10-28flash/nor/nrf5: fix protection setting on nRF51Tomas Vanek1-26/+50
Protection setting has not ever worked. UICR CLENR0 register cannot be simply written but has to programmed because it resides in UICR page of the flash. Enable flash programming before writing CLENR0 and set back to r/o afterwards. Inform the user that reset might be required. Change-Id: Ib0f96c74ba3583ac33f4394ddb57d8c8895adf53 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5586 Tested-by: jenkins
2020-10-22flash/stm32l4: add support of STM32G4 category 4 devices (G491/G4A1)Tarek BOCHKATI1-1/+18
STM32G4 cat.4 devices are up to 512 KB of flash memory (single bank) organized into pages of 2KB each. Reference: RM0440 rev.4 Change-Id: I0f510e2806c8f824fff8083e2d4f90d68f01046b Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5793 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-10-14flash/nor/at91sam4: ATSAMG55x19 Rev.BBenedikt-Alexander Mokroß1-2/+70
Add support for ATSAMG55x19 Rev.B. Both chips have nearly the same cidr, however, Rev.B has an incremented version. Change-Id: I5939c41fa5d54c4d3bfb850964974b878f709d13 Signed-off-by: Benedikt-Alexander Mokroß <mokross@gessler.de> Reviewed-on: http://openocd.zylin.com/5825 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2020-09-27Add support of STM32H72x/73x 1M (0x483)Tarek BOCHKATI1-2/+23
STM32H72x/73x flash is similar to STM32H74x/75x, except STM32H72x/73x devices have only one single flash bank. Change-Id: I3d3422dc60234f8273172924f426200210f388cc Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5792 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-09-05flash: use proper format with uint32_tAntonio Borneo38-142/+141
Modify the format strings to properly handle uint32_t data types. Change the type of variable retval in 'nor/ambiqmicro.c' to match both the value to carry and the returned type of the function. Fix the prototype mismatch of function lpc2900_address2sector() between the header and the C file. Change-Id: I68ffba9bd83eec8132f83bff3af993861fd09d84 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5816 Tested-by: jenkins
2020-09-05flash: avoid checking for non NULL pointer to free itAntonio Borneo30-161/+71
The function free() can be called with a NULL pointer as argument, no need to check the argument before. If the pointer is NULL, no operation is performed by free(). Remove the occurrences of pattern: if (ptr) free(ptr); There are cases where the pointer is set to NULL after free(), but then re-assigned within few lines. Drop the setting to NULL when this is evident. Anyway, the compiler will remove the useless assignment so no reason to be too much aggressive in this change. Change-Id: I55b2ce7cbe201410016398933e34d33a4b66e30b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5811 Tested-by: jenkins