• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

Переписать произвольный кусок flash используя JLink

Можно ли переписать часть флэша, не трогая остальное, с помощью JLink-a? Программно писать флэш возможно, а может уже есть что-то готовое, что бы не изобретать велосипед с квадратными колесами?
Если тут изменить адрес (0x98000000) на свой, размер (0x100000) ужать до своего получится записывать кусок флэша?
Код:
h
r
w4 0x40000230,0x0000D3C4
w4 0x40000210,0x00200113
w4 0x400002C0,0x00110001
w4 0x40006008,0
w4 0x4000602C,0
w4 0x40006010,1
w4 0x40006014,2
w4 0x40006018,0
w4 0x4000601C,0
w4 0x4000604C,0
savebin fullflash.bin 0x98000000 0x100000
w4 0x40000210,0x211157
r
g
q
 

sharikov

Active member
Можно ли переписать часть флэша, не трогая остальное, с помощью JLink-a?
Если адрес и длина кратны блоку флэш (4096 байт) - нет проблем.
Если не кратны тоже можно но придется выполнить: чтение всех затрагиваемых блоков - стирание - вставка заменяемых данных данных - запись.
 
Адрес и размер кратные 4096 - это не проблема. Можно ли записать используя J-Link и приведенный выше скрипт, исправив одну строчку, например так:
Код:
savebin my_data.bin 0x980D0000 0x10000
 
Пока понял только то, что приведенный код для записи флэша не годится, т.к. он для чтения. Прочитать может любой кусок флэша. Попытка разобраться со скриптами JLink-а с помощью интуиции не принесла успеха. Пытался найти на segger.com описание языка этих скриптов, не нашел. Где можно найти это описание?
 

pvvx

Активный участник сообщества
Пытался найти на segger.com описание языка этих скриптов, не нашел. Где можно найти это описание?
3.2.1 Commands
UM08001_JLink.pdf в директории SEGGER\JLink_Vxxx\Doc\Manuals
В самом JLink.exe по команде [inline]?[/inline].
Код:
J-Link>?

Available commands are:
----------------------
f          Firmware info
h          halt
g          go
Sleep      Waits the given time (in milliseconds). Syntax: Sleep <delay>
s          Single step the target chip
st         Show hardware status
hwinfo     Show hardware info
mem        Read memory. Syntax: mem  [<Zone>:]<Addr>, <NumBytes> (hex)
mem8       Read  8-bit items. Syntax: mem8  [<Zone>:]<Addr>, <NumBytes> (hex)
mem16      Read 16-bit items. Syntax: mem16 [<Zone>:]<Addr>, <NumItems> (hex)
mem32      Read 32-bit items. Syntax: mem32 [<Zone>:]<Addr>, <NumItems> (hex)
w1         Write  8-bit items. Syntax: w1 [<Zone>:]<Addr>, <Data> (hex)
w2         Write 16-bit items. Syntax: w2 [<Zone>:]<Addr>, <Data> (hex)
w4         Write 32-bit items. Syntax: w4 [<Zone>:]<Addr>, <Data> (hex)
erase      Erase internal flash of selected device. Syntax: Erase
wm         Write test words. Syntax: wm <NumWords>
is         Identify length of scan chain select register
ms         Measure length of scan chain. Syntax: ms <Scan chain>
mr         Measure RTCK react time. Syntax: mr
q          Quit
qc         Close JLink connection and quit
r          Reset target         (RESET)
rx         Reset target         (RESET). Syntax: rx <DelayAfterReset>
RSetType   Set the current reset type. Syntax: RSetType <type>
Regs       Display contents of registers
wreg       Write register.   Syntax: wreg <RegName>, <Value>
moe        Shows mode-of-entry, meaning: Reason why CPU is halted
SetBP      Set breakpoint.   Syntax: SetBP <addr> [A/T] [S/H]
SetWP      Set Watchpoint. Syntax: <Addr> [R/W] [<Data> [<D-Mask>] [A-Mask]]
ClrBP      Clear breakpoint. Syntax: ClrBP  <BP_Handle>
ClrWP      Clear watchpoint. Syntax: ClrWP  <WP_Handle>
VCatch     Write vector catch. Syntax: VCatch <Value>
loadfile   Load data file into target memory.
             Syntax: loadfile <filename>, [<addr>]
             Supported extensions: *.bin, *.mot, *.hex, *.srec
             <addr> is needed for bin files only.
loadbin    Load *.bin file into target memory.
             Syntax: loadbin <filename>, <addr>
savebin    Saves target memory into binary file.
             Syntax: savebin <filename>, <addr>, <NumBytes>
verifybin  Verfies if the specified binary is already in the target memory at the specified address.
             Syntax: verifybin <filename>, <addr>
SetPC      Set the PC to specified value. Syntax: SetPC <Addr>
le         Change to little endian mode
be         Change to big endian mode
log        Enables log to file.  Syntax: log <filename>
unlock     Unlocks a device. Syntax: unlock <DeviceName>
           Type unlock without <DeviceName> to get a list of supported device names.
           nRESET has to be connected
term       Test command to visualize printf output from the target device, using DCC (SEGGER DCC handler running on target)
ReadAP     Reads a CoreSight AP register.
           Note: First read returns the data of the previous read.
           An additional read of DP reg 3 is necessary to get the data.
ReadDP     Reads a CoreSight DP register.
           Note: For SWD data is returned immediately.
           For JTAG the data of the previous read is returned.
           An additional read of DP reg 3 is necessary to get the data.
WriteAP    Writes a CoreSight AP register.
WriteDP    Writes a CoreSight DP register.
SWDSelect  Selects SWD as interface and outputs
           the JTAG -> SWD switching sequence.
SWDReadAP  Reads a CoreSight AP register via SWD.
           Note: First read returns the data of the previous read.
           An additional read of DP reg 3 is necessary to get the data.
SWDReadDP  Reads a CoreSight DP register via SWD.
           Note: Correct data is returned immediately.
SWDWriteAP Writes a CoreSight AP register via SWD.
SWDWriteDP Writes a CoreSight DP register via SWD.
Device     Selects a specific device J-Link shall connect to
           and performs a reconnect.
           In most cases explicit selection of the device is not necessary.
           Selecting a device enables the user to make use of the J-Link  flash programming functionality as well as using unlimited breakpoints in flash memory.
           For some devices explicit device selection is mandatory in order to allow the DLL to perform special handling needed by the device.
ExpDevList Exports the device names from the DLL internal device list to a text file
             Syntax: ExpDevList <Filename>
PowerTrace Perform power trace (not supported by all models)
Syntax: PowerTrace <LogFile> [<ChannelMask> <RefCountSel>]
<LogFile>: File to store power trace data to
<ChannelMask>: 32-bit mask to specify what channels shall be enabled
<SampleFreq>: Sampling frequency in Hz (0 == max)
<RefCountSel>:       0: No reference count
                     1: Number of bytes transmitted on SWO
---- CP15 ------------
rce        Read CP15.  Syntax: rce <Op1>, <CRn>, <CRm>, <Op2>
wce        Write CP15. Syntax: wce <Op1>, <CRn>, <CRm>, <Op2>, <Data>
---- ICE -------------
Ice        Show state of the embedded ice macrocell (ICE breaker)
ri         Read Ice reg.  Syntax: ri <RegIndex>(hex)
wi         Write Ice reg. Syntax: wi <RegIndex>, <Data>(hex)
---- TRACE -----------
TClear     TRACE - Clear buffer
TSetSize   TRACE - Set Size of trace buffer
TSetFormat TRACE - SetFormat
TSR        TRACE - Show Regions (and analyze trace buffer)
TStart     TRACE - Start
TStop      TRACE - Stop
---- SWO -------------
SWOSpeed   SWO - Show supported speeds
SWOStart   SWO - Start
SWOStop    SWO - Stop
SWOStat    SWO - Display SWO status
SWORead    SWO - Read and display SWO data
SWOShow    SWO - Read and analyze SWO data
SWOFlush   SWO - Flush data
SWOView    SWO - View terminal data
---- PERIODIC --------
PERConf    PERIODIC - Configure
PERStart   PERIODIC - Start
PERStop    PERIODIC - Stop
PERStat    PERIODIC - Display status
PERRead    PERIODIC - Read and display data
PERShow    PERIODIC - Read and analyze data
---- File I/O --------
fwrite     Write file to emulator
fread      Read file from emulator
fshow      Read and display file from emulator
fdelete    Delete file on emulator
fsize      Display size of file on emulator
flist      List directory on emulator
SecureArea Creates/Removes secure area on probe
---- Test ------------
TestHaltGo   Run go/halt 1000 times
TestStep     Run step 1000 times
TestCSpeed   Measure CPU speed.
             Parameters: [<RAMAddr>]
TestWSpeed   Measure download speed into target memory.
             Parameters:  [<Addr> [<Size>]]
TestRSpeed   Measure upload speed from target memory.
             Parameters: [<Addr> [<Size>] [<NumBlocks>]]
TestNWSpeed  Measure network download speed.
             Parameters: [<NumBytes> [<NumReps>]]
TestNRSpeed  Measure network upload speed.
             Parameters: [<NumBytes> [<NumReps>]]
---- JTAG ------------
Config     Set number of IR/DR bits before ARM device.
             Syntax: Config <IRpre>, <DRpre>
speed      Set target interface speed. Syntax: speed <freq>|auto|adaptive, e.g.
speed 2000, speed a
i          Read JTAG Id (Host CPU)
wjc        Write JTAG command (IR). Syntax: wjc <Data>(hex)
wjd        Write JTAG data (DR). Syntax: wjd <Data64>(hex), <NumBits>(dec)
RTAP       Reset TAP Controller using state machine (111110)
wjraw      Write Raw JTAG data. Syntax: wjraw <NumBits(dec)>, <tms>, <tdi>
rt         Reset TAP Controller (nTRST)
---- JTAG-Hardware ---
c00        Create clock with TDI = TMS = 0
c          Clock
tck0       Clear TCK
tck1       Set   TCK
0          Clear TDI
1          Set   TDI
t0         Clear TMS
t1         Set   TMS
trst0      Clear TRST
trst1      Set   TRST
r0         Clear RESET
r1         Set   RESET
---- Connection ------
usb        Connect to J-Link via USB.  Syntax: usb <port>, where port is 0..3
ip         Connect to J-Link ARM Pro or J-Link TCP/IP Server via TCP/IP.
           Syntax: ip <ip_addr>
---- Configuration ---
si         Select target interface. Syntax: si <Interface>,
           where <Interface> can be any supported target interface (e.g SWD, JTAG, ICSP, FINE, ...
power      Switch power supply for target. Syntax: power <State> [perm], where State is either On or Off. Example: power on perm
wconf      Write configuration byte. Syntax: wconf <offset>, <data>
rconf      Read configuration bytes. Syntax: rconf
license    Shows a list of all available license commands
ipaddr     Show/Assign IP address and subnetmask of/to the connected J-Link.
gwaddr     Show/Assign network gateway address of/to the connected J-Link.
dnsaddr    Show/Assign network DNS server address of/to the connected J-Link.
conf       Show configuration of the connected J-Link.
calibrate  Calibrate the target current measurement.
selemu     Select a emulator to communicate with,  from a list of all emulators which are connected to the host
           The interfaces to search on, can be specified
             Syntax: selemu [<Interface0> <Interface1> ...]
ShowEmuList Shows a list of all emulators which are connected to the host.
            The interfaces to search on, can be specified.
             Syntax: ShowEmuList [<Interface0> <Interface1> ...]
----------------------
J-Link>
Какая тут "интуиция", если всё изначально дано в стандартном виде?
 
Последнее редактирование:

sharikov

Active member
Если не можете разобраться со скриптами используйте Jflash.
Открываете проект RTL8710.jflash который лежит в папке flasher потом Target->Connect, Target->Manual programming->...
 

aloika

Active member
Alexey_new, чем дело-то кончилось? разобрались? Расскажите.

Если не можете разобраться со скриптами используйте Jflash.
Открываете проект RTL8710.jflash который лежит в папке flasher потом Target->Connect, Target->Manual programming->...
Им только считать можно, а для записи он лицензию просит.
 

aloika

Active member
Alexey_new, я сделал так. Создал файл 9000.bin длиной 4096 байт, там написал, что мне надо. А далее создаем в Эклипсе цель, например, flash9000 и пишем там всё также, как например, в цели flashwebfs (т.е. редактируем makefile и flasher.mk). Запускаем цель flash9000 и всё.
 
Сверху Снизу