1 / 78

uC/OS-II Real Time Kernel Porting on Atmega128 And His/Her Applications

uC/OS-II Real Time Kernel Porting on Atmega128 And His/Her Applications. Embedded System Design 2004 Fall, Term Project since October 06, 2004 Jongbin Park Sungkyunkwan University Digital Media Lab URL: http://media.skku.ac.kr. Embedded System Design 2004. Project Introduction

erika
Télécharger la présentation

uC/OS-II Real Time Kernel Porting on Atmega128 And His/Her Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. uC/OS-II Real Time Kernel Porting on Atmega128And His/Her Applications Embedded System Design 2004 Fall, Term Project since October 06, 2004 Jongbin Park Sungkyunkwan University Digital Media Lab URL: http://media.skku.ac.kr

  2. Embedded System Design 2004 • Project Introduction • Overview of uC/OS-II • Overview of Atmega128 • The Construction of Development Environment • uC/OS-II Porting on Atmega128 • Development of a Application • Project Conclusion Digital Media Lab 2004

  3. Project Objective(1) • Objective One • uC/OS-II Real Time Kernel Porting on Atmega128, which is a 8-bit RISC type Micro controller • Objective Two • And His Applications • (ex) Motor Control  Robot Joint Part • (ex) Display on Graphic LCD  Text, BMP, Movie display • (ex) uC/OS-II based “Task-Manager” like The MS-windows “Task-Manager”  Current Project Digital Media Lab 2004

  4. Project Objective(2) 1. Porting TaskManger 2. App (motor ctl) 4. App (ETC.) 3. App (GLCD) ETC. Digital Media Lab 2004

  5. Project Result (1) Digital Media Lab 2004

  6. Project Result (2) Digital Media Lab 2004

  7. Approach for this Project • Step 1. Prepare the Atmega128 MCU board • Step 2. Get uC/OS-II source code from Jean J. Labrosse • Our Project kernel Version is V2.76 • Step 3. Understand the architecture of uC/OS-II’s Real-Time Kernel • Step 4. Understand Atmega128 architecture and software development using GCC (winavr) compiler • Step 5. Compile the uC/OS-II source code, which is written in ANSI C with GCC or IAR compiler • Step 6. Development of Demo Application • Step 7. Debugging and final report Digital Media Lab 2004

  8. Embedded System Design 2004 • Project Introduction • Overview of uC/OS-II • Overview of Atmega128 • The Construction of Development Environment • uC/OS-II Porting on Atmega128 • Development of a Application • Project Conclusion Digital Media Lab 2004

  9. Many Porting Information FAQ and Development Intuitions !!! uC/OS-II support page • http://www.ucos-ii.com/ Digital Media Lab 2004

  10. 1 Idel task, 63 Appliction task = 64 tasks What is uC/OS-II ? • uC/OS-II, The Real-Time Kernel • Highly portable, • ROMable, • Very scalable, • Preemptive real-time • Multi-tasking kernel • For micro-processor • For micro-controller • uC/OS-II can manage up to 63 application tasks • Over 100 microprocessor ports available • GO to uC/OS world !!! Digital Media Lab 2004

  11. Prevent the Priority Inversion Problem What uC/OS-II can ? • uC/OS-II can manage up to 63 application tasks • (c.f.) windows 2000 ?, • (c.f.) linux ? • Semaphores • Mutual Exclusion Semaphores ( to reduce priority inversions) (added in V2.04) • Event Flags (added in V2.51) • Message Mailboxes • Message Queues • Task Management (Create, Delete, Change Priority, Suspend/Resume etc.) • Fixed Sized Memory Block management • Time management Digital Media Lab 2004

  12. uC/OS-II Kernel Architecture Digital Media Lab 2004

  13. Test.c OS_CFG.h INCLUDES.h Never Change OS_CPU.h OS_CPU_A.asm OS_CPU_C.c uC/OS-II Kernel Architecture Our Application uC/OS-II Application Specific Layer uC/OS-II Hardware independent Layer uC/OS-II Hardware Specific Layer Atmega128 (HardWare) Digital Media Lab 2004

  14. Embedded System Design 2004 • Project Introduction • Overview of uC/OS-II • Overview of Atmega128 • The Construction of Development Environment • uC/OS-II Porting on Atmega128 • Development of a Application • Project Conclusion Digital Media Lab 2004

  15. We can get the Specification Doc We can get the Application Notes Atmega128 support page • http://www.atmel.com/products/avr/ Digital Media Lab 2004

  16. What is Atmega128? • Atmel’s AVR, which microcontrollers • A RISC core running single cycle instructions  FAST • Internal oscillators, timers, UART, SPI, pull-up resistors, pulse width modulation, ADC, analog comparator and watch-doc timers  System On Chip • With on-chip in system programmable Flash and EEPROM  Very Easy Development • In order to optimize cost and get product to the market quickly  for Time to Market Digital Media Lab 2004

  17. Atmega128 feature (1) • Advanced RISC Architecture • Up to 16 MIPS Throughput at 16 MHz • On-chip 2-cycle Multiplier • Etc. • Nonvolatile program and data memories • 128 K bytes of In-System Reprogrammable Flash • 4 K bytes EEPROM • 4 K Bytes internal SRAM • Etc. Digital Media Lab 2004

  18. Atmega128 feature (2) • Peripheral Features • Two 8-bit Timer/Counters • Two Expanded 16-bit Timer/Counters • Two 8-bit PWM(Pulse Width Modulation) channels • 8-channels, 10-bit ADC(Analog to Digital Converter) • Dual Programmable Serial USARTs (UART0, UART1) • Master/Slave SPI serial interface • On-chip analog comparator • Etc. Digital Media Lab 2004

  19. Atmega128 Architecture Digital Media Lab 2004

  20. Digital Media Lab 2004

  21. ADC TIMERS RTC SPI CPU PWM TWI USART PWM FLASH RAM EEPROM Brown-Out Detector Brown-Out Detector Pull-ups on demand Reset Circuitry High-current outputs Output Stage Programmable Watchdog Calibrated On-Chip OSC Watchdog Costly Emulator OCD / JTAG ISP Programming Circuitry AVR, for a true single-chip solution Page from www.prochild.com AVR does not only give you that BUT ALSO AVR Digital Media Lab 2004 TO open the way to a truesingle-chip solution !

  22. The three AVR families Page from www.prochild.com Features ( 16KB - 128KB) Fully Compatible ( 1KB- 8KB ) Memory Density ( 1KB - 2KB ) Digital Media Lab 2004

  23. AVR Register File Page from www.prochild.com R0 R1 R2 R3 R26 XL X Pointer R27 XH R28 YL Y Pointer R29 YH R30 ZL Z Pointer R31 ZH Register File Digital Media Lab 2004

  24. Direct Register - ALU Connection Page from www.prochild.com Register File Register operations take ONE clock pulse on the EXTERNAL clock input ALU Digital Media Lab 2004

  25. 1 2 Done! Done! 1 2 Done! 1 2 1 Done! 2 Execute 2 Instructions Page from www.prochild.com PIC HC05 ‘C51 Digital Media Lab 2004

  26. FactoryProgramming • For stable release • Time saving Any other physical link ! The programming channels can be disabled to avoid any further download ! • Program through any interface (e.g. SPI, TWI) • Variable Boot Block Size • Allows 100% Secure Encrypted Remote updates Parallel • One of the fastest way to download • Compatible with major programmers • IEEE std. 1149.1 Compliant interface • Can program NVMs, fuses and lock bits • Used also to debug the application (On-Chip debugging) • Can be used to test the PCB (Boundary-Scan) JTAG ISP • The native 3-wire interface for a quick update in the field • Easy-to-use and efficient How to Program the Flash? Page from www.prochild.com SPM Digital Media Lab 2004

  27. 6-wire serial programming interface In-System Programmable Flash and EEPROM Page from www.prochild.com Your device sits in the application. It is clocked from the application clock, and Vcc can be as low as 2.7V. Now, with four logical signals + Ground, you can REPROGRAM THE FLASH AND THE EEPROM NO +12V PROGRAMMING VOLTAGE REQUIRED! Digital Media Lab 2004

  28. w Data to program can be obtained from the application, internal RAM or from outside x y The Boot Section can program : v From the Application, it’s possible to jump to the Boot Section y RESET y Boot Section and Application Section can be locked to avoid : u Application u After a Reset the device can start in Application or Boot Loader Mode Self Programming Security Page from www.prochild.com w x Boot Section The Application Section v The Boot Section w x Read Write Read and Write Digital Media Lab 2004

  29. I/O Pin Block Diagram Page from www.prochild.com DDRx 0 Pull-Up PORTx 0 PINx Physical Pin X X Direction: INPUT PORTx : Output data or Pull-up Control bit DDRx Data Direction Control Bit PINx : Pin Level bit Pull-Up: OFF (Tri-State) Digital Media Lab 2004

  30. Embedded System Design 2004 • Project Introduction • Overview of uC/OS-II • Overview of Atmega128 • The Construction of Development Environment • uC/OS-II Porting on Atmega128 • Development of a Application • Project Conclusion Digital Media Lab 2004

  31. 1 2 3 Binary format Intel hex Etc. 5 4 Hi @@ world!! Development Procedure Programmer or Artist Ultra Editor My Application code uC/OS-II source Makefile WinAVR GCC compiler For AVR MCU CodeVision ISP Programmer Atmega128 Digital Media Lab 2004

  32. Prepare the Atmega128 Main board • Atmega128, 16 Mhz (real-sys) Digital Media Lab 2004

  33. How can get the uC/OS-II kernal? • Get uC/OS-II source code • buy the book • MicroC/OS-II: The Real-Time Kernel (2nd Edition, Revised) (with Compact Disc) • Embedded systems building blocks • Our Project kernel Version • V2.76 Digital Media Lab 2004

  34. Ultra Editor and GCC compiler • Ultra Editor + GCC compiler (winavr) • http://www.project-hf.net//ehobby/Projects/Mp3_Jukebox/2_mcu.htm • Winavr (gcc compiler) : • http://winavr.sourceforge.net/ • Ultra-editor • ftp://ultraedit.com/ • Step 1. winavr install • Notice !!! : Set the “PATH” • Step 2. ultra-editor install & compile setting • Go to the http://www.project-hf.net//ehobby/Projects/Mp3_Jukebox/2_mcu.htm Ultra Editor My Application code uC/OS-II source Makefile WinAVR GCC compiler For AVR MCU Digital Media Lab 2004

  35. Ultra-editor compile setting • Ultra-editor compile setting • http://www.project-hf.net//ehobby/Projects/Mp3_Jukebox/2_mcu.htm Digital Media Lab 2004

  36. CodeVision Compiler • Codevision si a program of high talents • Avr C Compiler • ISP (In System Programming) •  Parallel(Printer) Port • UART communication Terminal • ETC.. http://www.hpinfotech.ro/ Digital Media Lab 2004

  37. Embedded System Design 2004 • Project Introduction • Overview of uC/OS-II • Overview of Atmega128 • The Construction of Development Environment • uC/OS-II Porting on Atmega128 • Development of a Application • Project Conclusion Digital Media Lab 2004

  38. Porting feature summary • Target board • Atmega128 (realsys minicom128), 16 MHz • (Case1) Without External SRAM  internal SRAM (4Kbytes) • (Case2) With External SRAM (32 Kbytes) • uC/OS-II Kernel Version • V-2.76 • Cross Compiler • WinAvr gcc compiler (GCC 3.3.2) with gcc licence • UART baud-rate • UART0, 115200, 8bits, None Parity, 1Stop-bits Digital Media Lab 2004

  39. Memory Sections : Default Map .text  Flash ROM (128 Kbytes) .data, .bss, heap, stack  internal SRAM Digital Media Lab 2004

  40. Memory Sections : Can we change the Section Map? (1) • Problem: If you want coding the very large program, How? So Small !! I want big big Program !!! Digital Media Lab 2004

  41. Memory Sections : Can we change the Section Map? (2) • Answer: We can it !!! We can speak to the Linker !!! • WinAvr’s Linker FLAGS (LDFLAGS) is the KEY • It is possible to tell the linker the SRAM address of the beginning of the .data section WinAVR Liner (in Makefile) LDFLAGS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x807fff LDFLAGS += -Wl,-Map=$(TARGET).map,--cref Digital Media Lab 2004

  42. Memory Sections : Can we change the Section Map? (3) • We can use the external SRAM • Aslo we can change the Section Map !! avr-gcc ... -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff ... Internal RAM: stack only, external RAM: variables and heap Digital Media Lab 2004

  43. Memory Sections : Can we change the Section Map? (4) • Q. If you want “malloc()” operation on a MCU? • It is a Quite challenge, But we can also it!!! avr-gcc ... -Wl,--defsym=__heap_start=0x802000,--defsym=__heap_end=0x803fff ... Internal RAM: variables and stack, external RAM: heap Digital Media Lab 2004

  44. Review of the Memory Sections.text section • Refer to the avr-libc documentation • The .text section • The actual machine instructions • Subdivided by the .initN and .finiN sections • In a Flash ROM #include <stdio.h> Int main(void) { while(1){ // always !!! printf(“Hi !!! \n”); } } .initN sections .finiN sections Digital Media Lab 2004

  45. Review of the Memory Sections :.data section • The .data section • Static data char err_str[] = "Your program has died a horrible death!"; struct point pt = { 1, 1 }; char my_mind = “I miss you ^^”; // 매우 그립소 char your_mind = “Your mind is just a springtime fantasy”; // 꿈 깨시오, 일장춘몽이오 Digital Media Lab 2004

  46. Review of the Memory Sections :.bss, .eeprom, .noinit, .initN, finiN • .bss • Global • Static variables • .eeprom • This is where eeprom variables are stored. • .noinit • a part of the .bss section • .initN • define the startup code from reset up through the start of main() • These all are subparts of the .text section • The purpose of these sections is to allow for more specific placement of code within your program. • .finiN • define the exit code executed after return from main() or a call to exit() Digital Media Lab 2004

  47. (Case 1) In internal SRAM uC/OS-II and Simple Application Internal SRAM External SRAM (Case 2) With External SRAM 32 Kbytes uC/OS-II and More Complex Applicatons Actual Porting 0x0000 4 K 0x10ff 0x1100 32 K 0x7FFF Digital Media Lab 2004

  48. in Makefile LDFLAGS += -Wl,-Map=$(TARGET).map,--cref In Application File (Enable the Exeternal RAM) outp(0x80, MCUCR); in Makefile (setting the Loader Flag) LDFLAGS = -Wl,-Tdata=0x801100 ,--defsym=__heap_end=0x807fff LDFLAGS += -Wl,-Map=$(TARGET).map,--cref Loader Setting Case 1 0x0000 4 K 0x10ff Case 2 0x1100 32 K 0x7FFF Digital Media Lab 2004

  49. Retouching the uC/OS-Kernel Digital Media Lab 2004

  50. Test.c OS_CFG.h INCLUDES.h Never Change OS_CPU.h OS_CPU_A.asm OS_CPU_C.c Retouching the uC/OS-Kernel Our Application uC/OS-II Application Specific Layer uC/OS-II Hardware independent Layer uC/OS-II Hardware Specific Layer Atmega128 (HardWare) Digital Media Lab 2004

More Related