블로그 이미지
안녕1999

카테고리

전체 (3067)
자바스크립트 (20)
안드로이드 (14)
WebGL (4)
변비 (17)
정치,경제 (35)
C언어,ARM (162)
컴퓨터(PC, Note Book, 윈.. (41)
전자회로, PCB (27)
유머,안웃긴,GIF,동영상 (118)
국부론60 (71)
모듈(PCB) (3)
건강 (2)
FreeCAD (25)
PADS (43)
퇴직,퇴사,구직,취업 활동 (3)
C# (86)
엑셀 (8)
워드 (0)
LabView (6)
레고 (30)
FPGA (0)
Total
Today
Yesterday

달력

« » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

공지사항

최근에 올라온 글

'flash'에 해당되는 글 3건

  1. 2017.03.25 STM32 UART로 프로그램 다운로드
  2. 2016.10.07 STM32 - FLASH write
  3. 2016.09.09 STMicroelectronics flash loader 배치파일

STM32 칩중에는 프로그램을 UART로 다운로드할 수 있는 기능이 있는 칩이 있다.

이를 활용하면, RS-232케이블만 있다면, 프로그램 다운로딩이 가능하다.


개발할때 JTAG나 ISP장비가 없어도 된다.

제품이 현장설치된 경우, 고객이 직접 다운로딩도 가능하여, 유지보수에도 효과적이다.


STM32 Flash loader demonstrator

=========================================

다운로드 프로그램 : http://www.st.com/en/development-tools/flasher-stm32.html

가입(로그인)이 필요하다.


 Download Databrief 

USART1 (PA9/PA10)로 RS-232 통신이 되도록, 장비를 구성해 놓아야 한다.


HEX파일 다운로드 방법

===============================

1) PC에서 다운로드 프로그램을 실행하고,

2) 장비에서 다운로드 스위치 ON

3) 장비 리셋

4) PC에서 다운로드 진행

5) 장비에서 다운로드 스위치 OFF

6) 장비 리셋


언제나 그렇듯이, 데이터쉬트의 말은 반은 맞고, 반은 알기 어렵다.

아래 테이블을 보고, 2번째항목이, 프로그램 다운로드 모드라는걸 알기는 쉽지 않다.

아래는 Reference manual에 나와있는 내용이다. (데이터쉬트가 아니다.)

USART protocol used in the STM32 bootloader 

.

Posted by 안녕1999
, |
stm32f2xx_flash.h등의 파일을 include해야한다.

FLASH는 쓰기위해서는 먼져 삭제해야한다.

FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange);

FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange); 



쓰기함수는 3가지가 있다. 버퍼쓰기함수는 만들어야할듯.

FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);

FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);

FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data); 

지우기는 섹터단위이고, 쓰기는 주소이다. 각 섹터의 주소가 어디인지 알아야한다.



현재 상태나, 이전 쓰기,지우기등의 동작 결과 확인함수

FLASH_Status FLASH_GetStatus(void); 

FLASH_Status FLASH_WaitForLastOperation(void);


리턴값은 아래와 같다.

typedef enum

  FLASH_BUSY = 1,

  FLASH_ERROR_PGS,

  FLASH_ERROR_PGP,

  FLASH_ERROR_PGA,

  FLASH_ERROR_WRP,

  FLASH_ERROR_PROGRAM,

  FLASH_ERROR_OPERATION,

  FLASH_COMPLETE

}FLASH_Status; 


전압이 너무 낮으면, 사용할 수 없다. 현재 사용하는 전압을 설정해준다.

"꼭 해야되?"

=>CPU 전압에 따라 동작할 수 도 있고, 안될 수 도 있다.

#define VoltageRange_1        ((uint8_t)0x00)  /*!< Device operating range: 1.8V to 2.1V */

#define VoltageRange_2        ((uint8_t)0x01)  /*!<Device operating range: 2.1V to 2.7V */

#define VoltageRange_3        ((uint8_t)0x02)  /*!<Device operating range: 2.7V to 3.6V */

#define VoltageRange_4        ((uint8_t)0x03)  /*!<Device operating range: 2.7V to 3.6V + External Vpp */ 


#define FLASH_Sector_0     ((uint16_t)0x0000) /*!< Sector Number 0 */

#define FLASH_Sector_1     ((uint16_t)0x0008) /*!< Sector Number 1 */

#define FLASH_Sector_2     ((uint16_t)0x0010) /*!< Sector Number 2 */

#define FLASH_Sector_3     ((uint16_t)0x0018) /*!< Sector Number 3 */

#define FLASH_Sector_4     ((uint16_t)0x0020) /*!< Sector Number 4 */

#define FLASH_Sector_5     ((uint16_t)0x0028) /*!< Sector Number 5 */

#define FLASH_Sector_6     ((uint16_t)0x0030) /*!< Sector Number 6 */

#define FLASH_Sector_7     ((uint16_t)0x0038) /*!< Sector Number 7 */

#define FLASH_Sector_8     ((uint16_t)0x0040) /*!< Sector Number 8 */

#define FLASH_Sector_9     ((uint16_t)0x0048) /*!< Sector Number 9 */

#define FLASH_Sector_10    ((uint16_t)0x0050) /*!< Sector Number 10 */

#define FLASH_Sector_11    ((uint16_t)0x0058) /*!< Sector Number 11 */ 


내장된 플래시메모리는, 코드가 실행중에는 삭제/쓰기가 안된다.(읽기는 됨)

그래서 RAM에 쓰기관련 코드를 올려서, RAM에서 실행하면서, FLASH에 쓰면, 모든 영역의 FLASH에 쓰기를 할 수 있다.


FLASH가 섹터별로 나뉜 이유는, 사용하지 않는 섹터는 쓰기가 가능하다.

따라서, FLASH 사이즈가 256k이고, 프로그램 코드가 64k인 경우, 64k를 제외한 나머지 영역에 존재하는 섹터는 데이터용으로 쓰기가 가능하다.


IAP와 같은 부트로더 제작도 가능.



In-Application Programming (IAP)



RM0090

위 표는 "STMicroelectronics flash loader.exe"화면에 나온다.






FLASH_Latency_2, VoltageRange_1 정도로 설정하면, 동작함.

프로그램코드도 지워진다.(정지함)


FLASH는 EEPROM과 달리, 한번 기록되면, 다시쓰기위해 Erase해주어야한다.

또한, EEPROM처럼 수시로 업데이트가 불가능하다.

한번 저장하면, 오래 사용하는 데이터를 저장하기에 적당한 메모리이다.


FLASH_Unlock();

쓰기()

FLASH_Lock();

Posted by 안녕1999
, |
STMicroelectronics flash loader를 배치파일(도스명령)로 실행할 수 있다.

마우스로 이리저리 클릭하는것보다는 간편하나, HEX파일명, 포트번호가 고정되어 있어야한다.


STMicroelectronics UART Flash Loader command line v2.5.0 


 Usage : 


 STMFlashLoader.exe [options] [Agrument][[options] [Agrument]...] 


  -?                   (Show this help) 

  -c                   (Establish connection to the COM port) 

     --pn  port_nb     : e.g: 1, 2 ..., default 1 

     --br  baud_rate   : e.g: 115200, 57600 ..., default 57600 

     --db  data_bits   : value in {5,6,7,8} ..., default 8 

     --pr  parity      : value in {NONE,ODD,EVEN} ..., default EVEN 

     --sb  stop_bits   : value in {1,1.5,2} ..., default 1 

     --ec  echo        : value OFF or ECHO or LISTEN ..., default is OFF 

     --co  control     : Enable or Disable RTS and DTR outputs control  

                       : value OFF or ON ..., default is OFF 

     --to  time_out    : (ms) e.g 1000, 2000, 3000 ..., default 5000 

  -Rts                 (set Rts line to Hi, Lo)

     --State           : State in {Hi, Lo} 

  -Dtr                 (Set Rts line to Hi, Lo)

     --State           : State in {Hi, Lo}

  -i  device_name      (e.g STM32_Low-density_16K, [See the Map directory]) 

  -e                   (erase flash pages

     --all all pages   : erase all pages

     --sec number_of_pages_group pages_group_codes : erase specified group pages 

  -u                   (Upload flash contents to a .bin, .hex or .s19 file )

     --fn  file_name   : full path name of the file 

  -d                   (Download the content of a file into MCU flash) 

     --a   address(hex): start @ in hex ; ignored if it is not a binary file 

     --fn  file_name   : full path name (.bin, .hex or .s19 file) 

     --v               : verify after download 

     --o               : optimize; removes FFs data 

  -r                   (Run the flash code at the specified address 

     --a address(hex)  : address in hexadecimal) 

  -p        (Enable or Disable protections) 

     --ewp  : enable write protection for sector codes (e.g 1,2,etc.) 

     --dwp  : disable write protection 

     --drp  : disable read protection 

     --erp  : enable read protection, all arguments following this one will fail 

  -o              (Get or Set STM32F1x option bytes: use -d command for others!) 

     --get --fn file_name : get option bytes from the device 

                            and write it in the specified file 

     --set --fn file_name : load option bytes from the specified file 

                            and write it to the device 

     --set --vals --OPB hex_val : set the specified option byte; OPB in: User, 

                                  RDP, Data0, Data1, WRP0, WRP1, WRP2, WRP3 

 



파일명, 포트번호는 적당히 변경해야함.

echo COM1 = --pn 1   COM3 = --pn 3


"C:\Program Files\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe" ^

 -c --pn 3 --br 115200 --db 8 --pr EVEN --sb 1 --ec OFF --to 10000 --co ON -Dtr --Hi -Rts --Lo ^

 -i STM32F2_1024K -d --fn "D:\xxxxxxxxxxxxxxx\main.hex" --v -Dtr --Lo -Rts --Hi --Lo







Posted by 안녕1999
, |

최근에 달린 댓글

글 보관함