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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
Description: GNU coding standard --help and --version output
Author: Milan Kupcevic <milan@debian.org>
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/argparse/argparse.c
+++ b/argparse/argparse.c
@@ -24,6 +24,7 @@
***
**/
+#include "help.h"
#include "infohelper.h"
#include "argparse_binimagecmd.h"
#include "argparse_commcmd.h"
@@ -63,6 +64,26 @@
return 1;
break;
+ // help or version
+ case '-':
+ switch(arg_ptr[0][2])
+ {
+ // help
+ case 'h':
+ help();
+ break;
+
+ // version
+ case 'v':
+ version();
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+ break;
+
default:
return 0;
break;
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@
VERSION ?= $(shell git describe --always)
-MODULES := infohelper elf binimage argparse serialport espcomm
+MODULES := help infohelper elf binimage argparse serialport espcomm
-include local/Makefile.local.$(TARGET_OS)
@@ -48,6 +48,7 @@
espcomm/espcomm.o \
espcomm/espcomm_boards.o \
infohelper/infohelper.o \
+ help/help.o \
serialport/serialport.o \
main.o
--- /dev/null
+++ b/help/help.c
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ *******************************************************************************
+ ***
+ *** help.c
+ *** - help and version output formatted for help2man processing
+ ***
+ *** Copyright (C) 2016 Milan Kupcevic <milan@debian.org>
+ ***
+ *** This program is free software; you can redistribute it and/or modify
+ *** it under the terms of the GNU General Public License as published by
+ *** the Free Software Foundation; either version 2 of the License, or
+ *** (at your option) any later version.
+ ***
+ *** This program is distributed in the hope that it will be useful,
+ *** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *** GNU General Public License for more details.
+ ***
+ *** You should have received a copy of the GNU General Public License along
+ *** with this program; if not, write to the Free Software Foundation, Inc.,
+ *** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ ***
+ **/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "help.h"
+
+void
+version()
+{
+ puts(
+"esptool (esptool-ck) " VERSION "\n"
+"Copyright (C) 2014, 2015, 2016 Christian Klippel, Ivan Grokhotkov, Milan Kupcevic.\n"
+"This program comes with ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY\n"
+"or FITNESS FOR A PARTICULAR PURPOSE. This program is licensed under the\n"
+"terms of the GNU GPL version 2 or any later version as published by the Free\n"
+"Software Foundation.\n"
+"Written by Christian Klippel."
+ );
+ exit(EXIT_SUCCESS);
+}
+
+void
+help()
+{
+ puts(
+"\n"
+"Usage: esptool [FLASH OPTION]...\n"
+" or: esptool [CREATION OPTION]...\n"
+"\n"
+"Flash firmware files to ESP8266 or ESP32 boards with ability to \n"
+"automatically put certain boards into UART bootloader programming mode. Or, \n"
+"extract code sections from ELF executable files to create firmware files \n"
+"for ESP chips.\n"
+"\n"
+"Options:\n"
+"Flash:\n"
+" -cp <device> Select a serial port device to communicate \n"
+" with an ESP chip. Default is /dev/ttyUSB0 on \n"
+" Linux, COM1 on Windows and /dev/tty.usbserial \n"
+" on Mac OS X.\n"
+" -cb <baudrate> Select the baud rate. Default is 115200.\n"
+" -ca <address> Flash memory address to upload the data \n"
+" to. Default is 0x00000000.\n"
+" -cf <filename> Upload the file to flash memory. Serial \n"
+" communication parameters and flash memory \n"
+" address must precede this argument.\n"
+" -cp <size> Pad last written section to the given size, \n"
+" in bytes.\n"
+" -cc <chip> Select chip to upload to. Currently supported \n"
+" values are: esp8266 (default), esp32.\n"
+" -cd <board> Reset board into bootloader mode. \n"
+" Default is none.\n"
+"\n"
+"Resetting methods:\n"
+" nodemcu GPIO0 and RESET are controlled by two NPN \n"
+" transistors as implemented in NodeMCU devkit.\n"
+" wifio TXD controls GPIO0 via a PNP transistor, \n"
+" while DTR controls RESET via a capacitor.\n"
+" ck RTS controls RESET or CH_PD, while DTR \n"
+" controls GPIO0;\n"
+" none No DTR/RTS manipulation.\n"
+"\n"
+"Firmware creation:\n"
+" -eo <filename> Open an ELF object file, parse it and cache \n"
+" information found therein. Only one input \n"
+" file could be opened at a time.\n"
+" -es <section> <filename> Read the given section from currently opened \n"
+" input file and make raw dump into the \n"
+" specified file.\n"
+" -ec Close the currently opened input file.\n"
+"\n"
+" -bo <filename> Prepare a new firmware image file for writing.\n"
+" -bm <qio|qout|dio|dout> Set the flash chip interface mode. Default is \n"
+" QIO. This parameter is stored in the firmware \n"
+" image header along with the flash size and \n"
+" flash frequency. ROM bootloader in the ESP \n"
+" chip uses this info to know how to talk to \n"
+" the flash memory chip.\n"
+" -bz <512K|256K|1M|2M|4M|8M|16M|32M>\n"
+" Set the flash chip size. Default is 512K.\n"
+" -bf <40|26|20|80> Set the flash chip frequency in MHz. \n"
+" Default is 40M.\n"
+" -bs <section> Read the specified section from the input \n"
+" file and append it to the firmware image. The \n"
+" sections will appear in the same order as the \n"
+" -bs options appear on the command line.\n"
+" -bc Flush the content into the firmware image and \n"
+" close the file.\n"
+"\n"
+"Other:\n"
+" -v Display verbose informational messages. \n"
+" Add more v's to increase verbosity level, \n"
+" e.g. -vv, -vvv.\n"
+" -q Suppress informational messages.\n"
+"\n"
+" --help Display help.\n"
+" --version Display program version information.\n"
+"\n"
+"\n"
+"Examples:\n"
+"Flash Lua script firmware to a NodeMCU board: \n"
+"\n"
+" esptool -cd nodemcu -cf nodemcu_integer_0.9.5_20150318.bin\n"
+"\n"
+"Flash MicroPython for ESP8266 firmware to a Huzzah or EzSBC ESP board: \n"
+"First reset the board into flash programming mode. Holod GPIO0/Flash button \n"
+"and press reset button, release the reset button and finally release \n"
+"the GPIO0/Flash button. Then run the following command:\n"
+"\n"
+" esptool -cf firmware-combined.bin\n"
+"\n"
+"Flash Espressif AT v0.50 firmware to an ESP board: First manually reset \n"
+"the board into flash programming mode or use correct -cd option, then run: \n"
+"\n"
+" esptool -ca 0x00000 -cf noboot/eagle.flash.bin -ca 0x40000 -cf noboot/eagle.irom0text.bin -ca 0x3e000 -cf blank.bin -ca 0x7c000 -cf esp_init_data_default.bin -ca 0x7E000 -cf blank.bin\n"
+"\n"
+"Create firmware files from app.elf. Note the option for 4M flash size.\n"
+"\n"
+" esptool -bz 4M -eo app.elf -bo app_00000.bin -bs .text -bs .data -bs .rodata -bc -ec -eo app.elf -es .irom0.text app_40000.bin -ec\n"
+"\n"
+"Then, flash the created firmware to the board:\n"
+"\n"
+" esptool -cf 00000.bin -ca 0x40000 -cf 40000.bin\n"
+"\n"
+ );
+ exit(EXIT_SUCCESS);
+}
+
--- /dev/null
+++ b/help/help.h
@@ -0,0 +1,32 @@
+/**********************************************************************************
+ **********************************************************************************
+ ***
+ *** help.h
+ *** - include file for help.c
+ ***
+ *** Copyright (C) 2016 Milan Kupcevic <milan@debian.org>
+ ***
+ *** This program is free software; you can redistribute it and/or modify
+ *** it under the terms of the GNU General Public License as published by
+ *** the Free Software Foundation; either version 2 of the License, or
+ *** (at your option) any later version.
+ ***
+ *** This program is distributed in the hope that it will be useful,
+ *** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *** GNU General Public License for more details.
+ ***
+ *** You should have received a copy of the GNU General Public License along
+ *** with this program; if not, write to the Free Software Foundation, Inc.,
+ *** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ ***
+ **/
+
+
+#ifndef HELP_H
+#define HELP_H
+
+void help();
+void version();
+
+#endif
|