James Randall / Mbed 2 deprecated Just4Trionic

Dependencies:   mbed

Fork of Just4Trionic by Sophie Dexter

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bdm.cpp Source File

bdm.cpp

00001 /*******************************************************************************
00002 
00003 bdm.cpp
00004 (c) 2010 by Sophie Dexter
00005 
00006 BDM functions for Just4Trionic by Just4pLeisure
00007 
00008 A derivative work based on:
00009 //-----------------------------------------------------------------------------
00010 //    Firmware for USB BDM v2.0
00011 //    (C) johnc, 2009
00012 //    $id$
00013 //-----------------------------------------------------------------------------
00014 
00015 ********************************************************************************
00016 
00017 WARNING: Use at your own risk, sadly this software comes with no guarantees.
00018 This software is provided 'free' and in good faith, but the author does not
00019 accept liability for any damage arising from its use.
00020 
00021 *******************************************************************************/
00022 
00023 #include "bdm.h"
00024 
00025 // constants
00026 #define CMD_BUF_LENGTH      32              ///< command buffer size
00027 
00028 // LED constants and macros
00029 #define LED_ONTIME          5               ///< LED 'on' time, ms    
00030 #define LED_TCNT            (255 - (unsigned char)((unsigned long)(LED_ONTIME * 1000L)  \
00031                             / (1000000L / (float)((unsigned long)XTAL_CPU / 1024L))))
00032 
00033 // command characters
00034 #define CMDGROUP_ADAPTER    'a'             ///< adapter commands 
00035 #define CMD_VERSION         'v'             ///< firmware version
00036 #define CMD_PINSTATUS       's'             ///< momentary status of BDM pins
00037 #define CMD_BKPTLOW         '1'             ///< pull BKPT low
00038 #define CMD_BKPTHIGH        '2'             ///< pull BKPT high
00039 #define CMD_RESETLOW        '3'             ///< pull RESET low
00040 #define CMD_RESETHIGH       '4'             ///< pull RESET high
00041 #define CMD_BERR_LOW        '5'             ///< pull BERR low
00042 #define CMD_BERR_HIGH       '6'             ///< pull BERR high
00043 #define CMD_BERR_INPUT      '7'             ///< make BERR an input
00044 
00045 
00046 #define CMDGROUP_MCU        'c'             ///< target MCU management commands
00047 #define CMD_STOPCHIP        'S'             ///< stop
00048 #define CMD_RESETCHIP       'R'             ///< reset
00049 #define CMD_RUNCHIP         'r'             ///< run from given address
00050 #define CMD_RESTART         's'             ///< restart
00051 #define CMD_STEP            'b'             ///< step
00052 
00053 #define CMDGROUP_FLASH      'f'
00054 #define CMD_GETVERIFY       'v'             ///< gets verification status
00055 #define CMD_SETVERIFY       'V'             ///< sets verification on/off
00056 #define CMD_DUMP            'd'             ///< dumps memory contents
00057 #define CMD_ERASE           'E'             ///< erase entire flash memory            
00058 #define CMD_WRITE           'w'             ///< writes to flash memory
00059 
00060 #define CMDGROUP_MEMORY     'm'             ///< target MCU memory commands
00061 #define CMD_READBYTE        'b'             ///< read byte from memory
00062 #define CMD_READWORD        'w'             ///< read word (2 bytes) from memory
00063 #define CMD_READLONG        'l'             ///< read long word (4 bytes) from memory
00064 #define CMD_DUMPBYTE        'z'             ///< dump byte from memory
00065 #define CMD_DUMPWORD        'x'             ///< dump word from memory
00066 #define CMD_DUMPLONG        'c'             ///< dump long word from memory
00067 #define CMD_WRITEBYTE       'B'             ///< write byte to memory
00068 #define CMD_WRITEWORD       'W'             ///< write word to memory
00069 #define CMD_WRITELONG       'L'             ///< write long word to memory
00070 #define CMD_FILLBYTE        'f'             ///< fill byte in memory
00071 #define CMD_FILLWORD        'F'             ///< fill word in memory
00072 #define CMD_FILLLONG        'M'             ///< fill long word in memory 
00073 
00074 #define CMDGROUP_REGISTER   'r'             ///< register commands
00075 #define CMD_READSYSREG      'r'             ///< read system register
00076 #define CMD_WRITESYSREG     'W'             ///< write system register
00077 #define CMD_READADREG       'a'             ///< read A/D register
00078 #define CMD_WRITEADREG      'A'             ///< write A/D register
00079 #define CMD_DISPLAYREGS     'd'             ///< BD32 like display all registers
00080 
00081 #define CMDGROUP_TRIONIC    'T'
00082 #define CMD_TRIONICDUMP     'D'             ///< dumps memory contents
00083 #define CMD_TRIONICWRITE    'F'             ///< writes to flash memory
00084 
00085 // static variables
00086 static char cmd_buffer[CMD_BUF_LENGTH];     ///< command string buffer
00087 static uint32_t cmd_addr;                   ///< address (optional)
00088 static uint32_t cmd_value;                  ///< value    (optional)
00089 static uint32_t cmd_result;                 ///< result
00090 
00091 // private functions
00092 uint8_t execute_bdm_cmd();
00093 
00094 void bdm_show_help();
00095 void bdm_show_full_help();
00096 
00097 // command argument macros
00098 #define CHECK_ARGLENGTH(len) \
00099     if (cmd_length != len + 2) \
00100         return TERM_ERR
00101 
00102 #define GET_NUMBER(target, offset, len)    \
00103     if (!ascii2int(target, cmd_buffer + 2 + offset, len)) \
00104         return TERM_ERR
00105 
00106 
00107 void bdm()
00108 {
00109 
00110     bdm_show_help();
00111     // set up LED pins
00112 //    SETBIT(LED_DIR, _BV(LED_ERR) | _BV(LED_ACT));
00113     // set up USB_RD and USB_WR pins
00114 //    SETBIT(USB_RXTX_DIR, _BV(USB_RD) | _BV(USB_WR));
00115 
00116     // enable interrupts
00117 //    sei();
00118 
00119     // load configuration from EEPROM
00120 //    verify_flash = eeprom_read_byte(&ee_verify);
00121 
00122 // Set some initial values to help with checking if the BDM connector is plugged in
00123     PIN_PWR.mode(PullDown);
00124     PIN_NC.mode(PullUp);
00125 //    PIN_DS.mode(PullUp);
00126     PIN_FREEZE.mode(PullUp);
00127     PIN_DSO.mode(PullUp);
00128 
00129     verify_flash = true;
00130 
00131     // main loop
00132     *cmd_buffer = '\0';
00133     char ret;
00134     char rx_char;
00135     while (true) {
00136         // read chars from USB
00137         if (pc.readable()) {
00138             // turn Error LED off for next command
00139             led4 = 0;
00140             rx_char = pc.getc();
00141             switch (rx_char) {
00142                     // 'ESC' key to go back to mbed Just4Trionic 'home' menu
00143                 case '\e':
00144                     reset_chip();
00145                     return;
00146                     // end-of-command reached
00147                 case TERM_OK :
00148                     // execute command and return flag via USB
00149                     ret = execute_bdm_cmd();
00150                     pc.putc(ret);
00151                     // reset command buffer
00152                     *cmd_buffer = '\0';
00153                     // light up LED
00154 //                    ret == TERM_OK ? led_on(LED_ACT) : led_on(LED_ERR);
00155                     ret == TERM_OK ? led3 = 1 : led4 = 1;
00156                     break;
00157                     // another command char
00158                 default:
00159                     // store in buffer if space permits
00160                     if (StrLen(cmd_buffer) < CMD_BUF_LENGTH - 1) {
00161                         StrAddc(cmd_buffer, rx_char);
00162                     }
00163                     break;
00164             }
00165         }
00166     }
00167 }
00168 
00169 //-----------------------------------------------------------------------------
00170 /**
00171     Executes a command and returns result flag (does not transmit the flag
00172     itself).
00173 
00174     @return                    command flag (success / failure)
00175 */
00176 uint8_t execute_bdm_cmd()
00177 {
00178     uint8_t cmd_length = strlen(cmd_buffer);
00179     char cmd = *(cmd_buffer + 1);
00180 
00181     // command groups
00182     switch (*cmd_buffer) {
00183             // adapter commands
00184         case CMDGROUP_ADAPTER:
00185             CHECK_ARGLENGTH(0);
00186             switch (cmd) {
00187                     // get firmware version
00188                 case CMD_VERSION:
00189                     printf("%02x", FW_VERSION_MAJOR);
00190                     printf("%02x", FW_VERSION_MINOR);
00191                     printf("\r\n");
00192                     return TERM_OK;
00193 
00194                     // get momentary status of BDM pins 0...5 (for debugging)
00195                 case CMD_PINSTATUS:
00196 //                    printf("%02x", (BDM_PIN & 0x3f));
00197                     printf("PWR %d, ", PIN_PWR.read());
00198                     printf("NC %d, ", PIN_NC.read());
00199 //                    printf("DS %d, ", PIN_DS.read());
00200                     printf("FREEZE %d, ", PIN_FREEZE.read());
00201                     printf("DSO %d, ", PIN_DSO.read());
00202                     printf("\r\n");
00203                     return TERM_OK;
00204 
00205                     // pull BKPT low
00206                 case CMD_BKPTLOW:
00207                     return bkpt_low();
00208 
00209                     // pull BKPT high
00210                 case CMD_BKPTHIGH:
00211                     return bkpt_high();
00212 
00213                     // pull RESET low
00214                 case CMD_RESETLOW:
00215                     return reset_low();
00216 
00217                     // pull RESET high
00218                 case CMD_RESETHIGH:
00219                     return reset_high();
00220 
00221                     // pull BERR low
00222                 case CMD_BERR_LOW:
00223                     return berr_low();
00224 
00225                     // pull BERR high
00226                 case CMD_BERR_HIGH:
00227                     return berr_high();
00228 
00229                     // make BERR an input
00230                 case CMD_BERR_INPUT:
00231                     return berr_input();
00232             }
00233             break;
00234 
00235             // MCU management
00236         case CMDGROUP_MCU:
00237             switch (cmd) {
00238                     // stop target MCU
00239                 case CMD_STOPCHIP:
00240                     return stop_chip();
00241 
00242                     // reset target MCU
00243                 case CMD_RESETCHIP:
00244                     return reset_chip();
00245 
00246                     // run target MCU from given address
00247                 case CMD_RUNCHIP:
00248                     CHECK_ARGLENGTH(8);
00249                     GET_NUMBER(&cmd_addr, 0, 8);
00250                     return run_chip(&cmd_addr);
00251 
00252                     // restart
00253                 case CMD_RESTART:
00254                     return restart_chip();
00255 
00256                     // step
00257                 case CMD_STEP:
00258                     return step_chip();
00259             }
00260             break;
00261 
00262             // Trionic dumping and flashing
00263         case CMDGROUP_FLASH:
00264             switch (cmd) {
00265                     // get verification flag
00266                 case CMD_GETVERIFY:
00267                     CHECK_ARGLENGTH(0);
00268                     printf("%02x", (uint8_t)verify_flash);
00269                     printf("\r\n");
00270                     return TERM_OK;
00271 
00272                     // set verification flag
00273                 case CMD_SETVERIFY:
00274                     CHECK_ARGLENGTH(2);
00275                     GET_NUMBER(&cmd_addr, 0, 2);
00276                     verify_flash = (bool)cmd_addr;
00277 //                    eeprom_write_byte(&ee_verify, verify_flash);
00278                     return TERM_OK;
00279 
00280                     // dump flash contents as block
00281                 case CMD_DUMP:
00282                     CHECK_ARGLENGTH(16);
00283                     GET_NUMBER(&cmd_addr, 0, 8);
00284                     GET_NUMBER(&cmd_value, 8, 8);
00285                     return dump_flash(&cmd_addr, &cmd_value);
00286 
00287                     // erase entire flash memory
00288                 case CMD_ERASE:
00289                     CHECK_ARGLENGTH(22);
00290                     GET_NUMBER(&cmd_addr, 6, 8);
00291                     GET_NUMBER(&cmd_value, 14, 8);
00292                     return erase_flash(cmd_buffer + 2, &cmd_addr, &cmd_value);
00293 
00294                     // write data block to flash memory
00295                 case CMD_WRITE:
00296                     CHECK_ARGLENGTH(14);
00297                     GET_NUMBER(&cmd_addr, 6, 8);
00298                     return write_flash(cmd_buffer + 2, &cmd_addr);
00299             }
00300             break;
00301 
00302             // memory
00303         case CMDGROUP_MEMORY:
00304             if (cmd != CMD_FILLBYTE && cmd != CMD_FILLWORD &&
00305                     cmd != CMD_FILLLONG && cmd != CMD_DUMPBYTE && cmd != CMD_DUMPWORD &&
00306                     cmd != CMD_DUMPLONG) {
00307                 // get memory address
00308                 if (cmd_length < 10 || !ascii2int(&cmd_addr, cmd_buffer + 2, 8)) {
00309                     // broken parametre
00310                     return TERM_ERR;
00311                 }
00312 
00313                 // get optional value
00314                 if (cmd_length > 10 &&
00315                         !ascii2int(&cmd_value, cmd_buffer + 10, cmd_length - 10)) {
00316                     // broken parametre
00317                     return TERM_ERR;
00318                 }
00319             }
00320 
00321             switch (cmd) {
00322                     // read byte
00323                 case CMD_READBYTE:
00324                     if (cmd_length != 10 ||
00325                             memread_byte((uint8_t*)(&cmd_result), &cmd_addr) != TERM_OK) {
00326                         return TERM_ERR;
00327                     }
00328                     printf("%02x", (uint8_t)cmd_result);
00329                     printf("\r\n");
00330                     return TERM_OK;
00331 
00332                     // read word
00333                 case CMD_READWORD:
00334                     if (cmd_length != 10 ||
00335                             memread_word((uint16_t*)(&cmd_result), &cmd_addr) != TERM_OK) {
00336                         return TERM_ERR;
00337                     }
00338                     printf("%04X", (uint16_t)cmd_result);
00339                     printf("\r\n");
00340                     return TERM_OK;
00341 
00342                     // read long word
00343                 case CMD_READLONG:
00344                     if (cmd_length != 10 ||
00345                             memread_long(&cmd_result, &cmd_addr) != TERM_OK) {
00346                         return TERM_ERR;
00347                     }
00348                     printf("%08X", cmd_result);
00349                     printf("\r\n");
00350                     return TERM_OK;
00351 
00352                     // dump byte
00353                 case CMD_DUMPBYTE:
00354                     if (cmd_length != 2 ||
00355                             memdump_byte((uint8_t*)(&cmd_result)) != TERM_OK) {
00356                         return TERM_ERR;
00357                     }
00358                     printf("%02x", (uint8_t)cmd_result);
00359                     printf("\r\n");
00360                     return TERM_OK;
00361 
00362                     // dump word
00363                 case CMD_DUMPWORD:
00364                     if (cmd_length != 2 ||
00365                             memdump_word((uint16_t*)(&cmd_result)) != TERM_OK) {
00366                         return TERM_ERR;
00367                     }
00368                     printf("%04X", (uint16_t)cmd_result);
00369                     printf("\r\n");
00370                     return TERM_OK;
00371 
00372                     // dump long word
00373                 case CMD_DUMPLONG:
00374                     if (cmd_length != 2 ||
00375                             memdump_long(&cmd_result) != TERM_OK) {
00376                         return TERM_ERR;
00377                     }
00378                     printf("%08X", cmd_result);
00379                     printf("\r\n");
00380                     return TERM_OK;
00381 
00382                     // write byte
00383                 case CMD_WRITEBYTE:
00384                     return (cmd_length == 12 &&
00385                             memwrite_byte(&cmd_addr, cmd_value) == TERM_OK) ?
00386                            TERM_OK : TERM_ERR;
00387 
00388                     // write word
00389                 case CMD_WRITEWORD:
00390                     return (cmd_length == 14 &&
00391                             memwrite_word(&cmd_addr, cmd_value) == TERM_OK) ?
00392                            TERM_OK : TERM_ERR;
00393 
00394                     // write long word
00395                 case CMD_WRITELONG:
00396                     return (cmd_length == 18 &&
00397                             memwrite_long(&cmd_addr, &cmd_value) == TERM_OK) ?
00398                            TERM_OK : TERM_ERR;
00399 
00400                     // fill byte
00401                 case CMD_FILLBYTE:
00402                     if (cmd_length != 4 || !ascii2int(&cmd_value, cmd_buffer + 2, 2)) {
00403                         return TERM_ERR;
00404                     }
00405                     return (memfill_byte(cmd_value));
00406 
00407                     // fill word
00408                 case CMD_FILLWORD:
00409                     if (cmd_length != 6 || !ascii2int(&cmd_value, cmd_buffer + 2, 4)) {
00410                         return TERM_ERR;
00411                     }
00412                     return (memfill_word(cmd_value));
00413 
00414                     // fill long word
00415                 case CMD_FILLLONG:
00416                     if (cmd_length != 10 || !ascii2int(&cmd_value, cmd_buffer + 2, 8)) {
00417                         return TERM_ERR;
00418                     }
00419                     return (memfill_long(&cmd_value));
00420             }
00421             break;
00422 
00423             // registers
00424         case CMDGROUP_REGISTER:
00425             // get register code
00426             if (cmd_length == 2 && (cmd != CMD_DISPLAYREGS)) {
00427                 // broken parametre
00428                 return TERM_ERR;
00429             } else {
00430                 if (cmd_length < 4 || !ascii2int(&cmd_addr, cmd_buffer + 3, 1)) {
00431                     // broken parametre
00432                     return TERM_ERR;
00433                 }
00434                 // get optional value
00435                 if (cmd_length > 4 &&
00436                         !ascii2int(&cmd_value, cmd_buffer + 4, 8)) {
00437                     // broken parametre
00438                     return TERM_ERR;
00439                 }
00440             }
00441 
00442             switch (cmd) {
00443                     // read system register
00444                 case CMD_READSYSREG:
00445                     if (cmd_length != 4 ||
00446                             sysreg_read(&cmd_result, (uint8_t)cmd_addr) != TERM_OK) {
00447                         return TERM_ERR;
00448                     }
00449                     printf("%08X", cmd_result);
00450                     printf("\r\n");
00451                     return TERM_OK;
00452 
00453                     // write system register
00454                 case CMD_WRITESYSREG:
00455                     return (cmd_length == 12 &&
00456                             sysreg_write((uint8_t)cmd_addr, &cmd_value) == TERM_OK) ?
00457                            TERM_OK : TERM_ERR;
00458 
00459                     // read A/D register
00460                 case CMD_READADREG:
00461                     if (cmd_length != 4 ||
00462                             adreg_read(&cmd_result, (uint8_t)cmd_addr) != TERM_OK) {
00463                         return TERM_ERR;
00464                     }
00465                     printf("%08X", cmd_result);
00466                     printf("\r\n");
00467                     return TERM_OK;
00468 
00469                     // write A/D register
00470                 case CMD_WRITEADREG:
00471                     return (cmd_length == 12 &&
00472                             adreg_write((uint8_t)cmd_addr, &cmd_value) == TERM_OK) ?
00473                            TERM_OK : TERM_ERR;
00474 
00475                     // Display all registers
00476                 case CMD_DISPLAYREGS:
00477                     printf(" D0-7");
00478                     for (uint8_t i = 0; i < 8; i++) {
00479                         if (adreg_read(&cmd_result, i) != TERM_OK) {
00480                             return TERM_ERR;
00481                         }
00482                         printf(" %08X", cmd_result);
00483                     }
00484 //
00485                     printf("\r\n");
00486                     printf(" A0-7");
00487                     for (uint8_t i = 8; i < 16; i++) {
00488                         if (adreg_read(&cmd_result, i) != TERM_OK) {
00489                             return TERM_ERR;
00490                         }
00491                         printf(" %08X", cmd_result);
00492                     }
00493                     printf("\r\n");
00494 //
00495                     if (sysreg_read(&cmd_result, 0x0) != TERM_OK) {
00496                         return TERM_ERR;
00497                     }
00498                     printf("  RPC %08X", cmd_result);
00499                     if (sysreg_read(&cmd_result, 0xC) != TERM_OK) {
00500                         return TERM_ERR;
00501                     }
00502                     printf("     USP %08X", cmd_result);
00503                     if (sysreg_read(&cmd_result, 0xE) != TERM_OK) {
00504                         return TERM_ERR;
00505                     }
00506                     printf("     SFC %08X      SR 10S--210---XNZVC\r\n", cmd_result);
00507 //
00508                     if (sysreg_read(&cmd_result, 0x1) != TERM_OK) {
00509                         return TERM_ERR;
00510                     }
00511                     printf("  CPC %08X", cmd_result);
00512                     if (sysreg_read(&cmd_result, 0xD) != TERM_OK) {
00513                         return TERM_ERR;
00514                     }
00515                     printf("     SSP %08X", cmd_result);
00516                     if (sysreg_read(&cmd_result, 0xF) != TERM_OK) {
00517                         return TERM_ERR;
00518                     }
00519                     printf("     DFC %08X", cmd_result);
00520                     if (sysreg_read(&cmd_result, 0xB) != TERM_OK) {
00521                         return TERM_ERR;
00522                     }
00523                     printf("    %04X ", cmd_result);
00524                     for (uint32_t i = 0; i < 16; i++) {
00525                         cmd_result & (1 << (15-i)) ? printf("1") : printf("0");
00526                     }
00527                     printf("\r\n");
00528 //
00529                     if (sysreg_read(&cmd_result, 0xA)!= TERM_OK) {
00530                         return TERM_ERR;
00531                     }
00532                     printf("  VBR %08X", cmd_result);
00533                     if (sysreg_read(&cmd_result, 0x8)!= TERM_OK) {
00534                         return TERM_ERR;
00535                     }
00536                     printf("   ATEMP %08X", cmd_result);
00537                     if (sysreg_read(&cmd_result, 0x9) != TERM_OK) {
00538                         return TERM_ERR;
00539                     }
00540                     printf("     FAR %08X\r\n", cmd_result);
00541 //
00542                     printf(" !CONNNECTED:%d", PIN_NC.read());
00543                     printf(" POWER:%d", PIN_PWR.read());
00544                     printf(" !RESET:%d", PIN_RESET.read());
00545                     printf(" !BUSERR:%d", PIN_BERR.read());
00546                     printf(" BKPT/DSCLK:%d", PIN_BKPT.read());
00547                     printf(" FREEZE:%d", PIN_FREEZE.read());
00548                     printf(" DSO:%d", PIN_DSO.read());
00549                     printf(" DSI:%d", PIN_DSI.read());
00550                     printf("\r\n");
00551 //
00552                     return TERM_OK;
00553             }
00554             break;
00555 
00556             // Trionic dumping and flashing
00557         case CMDGROUP_TRIONIC:
00558 
00559             switch (cmd) {
00560 
00561                     // dump flash contents to a bin file
00562                 case CMD_TRIONICDUMP:
00563                     CHECK_ARGLENGTH(0);
00564                     return dump_trionic();
00565 
00566                     // write data block to flash memory
00567                 case CMD_TRIONICWRITE:
00568                     CHECK_ARGLENGTH(0);
00569                     return flash_trionic();
00570             }
00571 
00572             // show help for BDM commands
00573         case 'H':
00574             bdm_show_full_help();
00575             return TERM_OK;
00576         case 'h':
00577             bdm_show_help();
00578             return TERM_OK;
00579         default:
00580             bdm_show_help();
00581     }
00582 
00583     // unknown command
00584     return TERM_ERR;
00585 }
00586 
00587 void bdm_show_help()
00588 {
00589     printf("Just4Trionic BDM Command Menu\r\n");
00590     printf("=============================\r\n");
00591     printf("TD - and DUMP T5 FLASH BIN file\r\n");
00592     printf("TF - FLASH the update file to the T5 (and write SRAM)\r\n");
00593     printf("Tr - Read SRAM adaption (not done).\r\n");
00594     printf("Tw - Write SRAM adaptation (not done).\r\n");
00595     printf("\r\n");
00596     printf("'ESC' - Return to Just4Trionic Main Menu\r\n");
00597     printf("\r\n");
00598     printf("h  - Show this help menu\r\n");
00599     printf("\r\n");
00600     return;
00601 }
00602 void bdm_show_full_help()
00603 {
00604     printf("Just4Trionic BDM Command Menu\r\n");
00605     printf("=============================\r\n");
00606     printf("TD - and DUMP T5 FLASH BIN file\r\n");
00607     printf("TF - FLASH the update file to the T5 (and write SRAM)\r\n");
00608     printf("Tr - Read SRAM adaption (not done).\r\n");
00609     printf("Tw - Write SRAM adaptation (not done).\r\n");
00610     printf("\r\n");
00611     printf("Adapter Commands - a\r\n");
00612     printf("====================\r\n");
00613     printf("av - display firmware version\r\n");
00614     printf("as - display status of BDM pins\r\n");
00615     printf("a1 - pull BKPT low\r\n");
00616     printf("a2 - pull BKPT high\r\n");
00617     printf("a3 - pull RESET low\r\n");
00618     printf("a4 - pull RESET high\r\n");
00619     printf("a5 - pull BERR low\r\n");
00620     printf("a6 - pull BERR high\r\n");
00621     printf("a7 - make BERR an input\r\n");
00622     printf("\r\n");
00623     printf("MCU Management Commands - c\r\n");
00624     printf("===========================\r\n");
00625     printf("cS - stop MCU\r\n");
00626     printf("cR - reset MCU\r\n");
00627     printf("cr - run from given address\r\n");
00628     printf("     e.g. crCAFEBABE run from address 0xcafebabe\r\n");
00629     printf("cs - restart MCU\r\n");
00630     printf("cb - step MCU\r\n");
00631     printf("\r\n");
00632     printf("MCU FLASH Commands - f\r\n");
00633     printf("======================\r\n");
00634     printf("fv - gets verification status (always verify)\r\n");
00635     printf("fV - sets verification on/off (always on)\r\n");
00636     printf("fd - DUMPs memory contents\r\n");
00637     printf("     e.g. fdSSSSSSSSEEEEEEEE S...E... start and end addresses\r\n");
00638     printf("     e.g. fd0000000000020000 to DUMP T5.2\r\n");
00639     printf("     e.g. fd0000000000040000 to DUMP T5.5\r\n");
00640     printf("     e.g. fd0000000000080000 to DUMP T7\r\n");
00641     printf("fE - Erases entire FLASH memory\r\n");
00642     printf("     e.g. fETTTTTTSSSSSSSSEEEEEEEE T...S...E type, start and end addresses\r\n");
00643     printf("     e.g. fE28f0100000000000020000 erase 28F512 in T5.2\r\n");
00644     printf("     e.g. fE28f0100000000000040000 erase 28F010 in T5.5\r\n");
00645     printf("     e.g. fE29f0100000000000040000 erase 29F010 in T5.5 (addresses not used)\r\n");
00646     printf("     e.g. fE29f4000000000000080000 erase 29F400 in T7 (addresses not used)\r\n");
00647     printf("fw - writes to FLASH memory\r\n");
00648     printf("     Write a batch of long words to flash from a start address\r\n");
00649     printf("     followed by longwords LLLLLLLL, LLLLLLLL etc\r\n");
00650     printf("     Send a break character to stop when doneg");
00651     printf("     e.g. fwTTTTTTSSSSSSSS T...S... type and start address\r\n");
00652     printf("     e.g. fw28f01000004000 start at address 0x004000 T5.2/5.5\r\n");
00653     printf("     e.g. fw29f01000004000 start at address 0x004000 T5.5 with 29F010\r\n");
00654     printf("     e.g. fw29f40000004000 start at address 0x004000 T7\r\n");
00655     printf("\r\n");
00656     printf("MCU Memory Commands - m\r\n");
00657     printf("=======================\r\n");
00658     printf("mbAAAAAAAA - read byte from memory at 0xaaaaaaaa\r\n");
00659     printf("mwAAAAAAAA - read word (2 bytes) from memory\r\n");
00660     printf("mlAAAAAAAA - read long word (4 bytes) from memory\r\n");
00661     printf("mz - dump byte from the next memory address\r\n");
00662     printf("mx - dump word from the next memory address\r\n");
00663     printf("mc - dump long word from the next memory address\r\n");
00664     printf("mBAAAAAAAADD - write byte 0xdd to memory 0xaaaaaaaa\r\n");
00665     printf("mWAAAAAAAADDDD - write word 0xdddd to memory 0xaaaaaaaa\r\n");
00666     printf("mLAAAAAAAADDDDDDD - write long word 0xdddddddd to memory 0xaaaaaaaa\r\n");
00667     printf("mfDD - fill byte 0xdd to next memory address\r\n");
00668     printf("mFDDDD - fill word 0xdddd to next memory address\r\n");
00669     printf("mMDDDDDDDD - fill long word 0xdddddddd to next memory address\r\n");
00670     printf("\r\n");
00671     printf("MCU Register Commands - r\r\n");
00672     printf("=========================\r\n");
00673     printf("rd     Display all registers (like BD32)\r\n");
00674     printf("rrRR - read system register RR\r\n");
00675     printf("       00 - RPC, 01 - PCC, 0B - SR, 0C - USP, 0D - SSP\r\n");
00676     printf("       0e - SFC, 0f - DFC, 08 - ATEMP, 09 - FAR, 0a - VBR\r\n");
00677     printf("rWRRCAFEBABE - write 0xcafebabe system register RR\r\n");
00678     printf("raAD - read A/D register 0x00-07 D0-D7, 0x08-15 A0-A7\r\n");
00679     printf("rAADCAFEBABE - write 0xcafebabe to A/D register \r\n");
00680     printf("\r\n");
00681     printf("'ESC' - Return to Just4Trionic Main Menu\r\n");
00682     printf("\r\n");
00683     printf("H  - Show this help menu\r\n");
00684     printf("\r\n");
00685     return;
00686 }