summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/tex/30pin.tex73
-rw-r--r--lib/30pin.h27
-rw-r--r--lib/bootnet.h18
3 files changed, 106 insertions, 12 deletions
diff --git a/docs/tex/30pin.tex b/docs/tex/30pin.tex
new file mode 100644
index 0000000..53ef393
--- /dev/null
+++ b/docs/tex/30pin.tex
@@ -0,0 +1,73 @@
+
+\documentclass{article}
+\usepackage{listings}
+\usepackage{xcolor}
+\usepackage{geometry}
+\usepackage{titlesec}
+\usepackage{fancyhdr}
+\usepackage{amsmath}
+\usepackage{amsfonts}
+\usepackage{graphicx}
+\usepackage{enumitem}
+\geometry{margin=1in}
+
+\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
+\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection}{1em}{}
+
+\title{\texttt{30pin.h} Specification}
+\author{Amlal EL Mahrouss}
+\date{2024}
+
+\lstset{
+ basicstyle=\ttfamily\footnotesize,
+ keywordstyle=\color{blue},
+ commentstyle=\color{gray},
+ stringstyle=\color{red},
+ showstringspaces=false,
+ breaklines=true
+}
+
+\begin{document}
+
+\maketitle
+
+\section*{File Description}
+\textbf{File:} \texttt{30pin.h} \\
+\textbf{Description:} This header defines the 30pin recovery protocol structures, constants, and packet kinds.
+
+\section{Constants}
+\begin{itemize}[leftmargin=2em]
+ \item \texttt{CB\_30PIN\_MAG} - Magic number identifier for a 30pin packet. Defined as \texttt{"TP"}.
+ \item \texttt{CP\_30PIN\_MAG\_LEN} - Length of the magic number (\texttt{2} bytes).
+ \item \texttt{CB\_30PIN\_BUFFER\_LEN} - Length of the data buffer in the packet (\texttt{498} bytes).
+ \item \texttt{CB\_30PIN\_EOP\_LEN} - Length of the end-of-packet data (\texttt{11} bytes).
+\end{itemize}
+
+\section{Data Structures}
+\subsection{\texttt{cb\_tpin\_recovery\_packet}}
+\begin{lstlisting}[language=C]
+struct _cb_tpin_recovery_packet
+{
+ uint8_t mag[CP_30PIN_MAG_LEN]; // Magic number
+ uint8_t kind; // Packet kind identifier
+ uint8_t buffer[CB_30PIN_BUFFER_LEN]; // Packet data buffer
+ uint8_t eop[CB_30PIN_EOP_LEN]; // End-of-packet data
+};
+\end{lstlisting}
+
+\textbf{Typedef:} \texttt{cb\_tpin\_recovery\_packet\_t}
+
+\section{Enumerations}
+\subsection{Packet Kinds}
+Defines the kinds of packets used in the 30pin recovery protocol:
+
+\begin{itemize}[leftmargin=2em]
+ \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_UNKNOWN = 0}
+ \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_BOOT = 1}
+ \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_DATA = 2}
+ \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP = 3}
+ \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP\_ACK = 4}
+ \item \texttt{TPIN\_RECOVERY\_PACKET\_KIND\_EOP\_NACK = 5}
+\end{itemize}
+
+\end{document}
diff --git a/lib/30pin.h b/lib/30pin.h
index 71d998d..d4f0de9 100644
--- a/lib/30pin.h
+++ b/lib/30pin.h
@@ -8,7 +8,15 @@
#include <lib/boot.h>
-/// @note This version is for the 30-pin recovery system.
+/// @file 30pin.h
+/// @brief 30pin recovery protocol.
+/// @details This file contains the definitions and structures used for the 30pin recovery protocol.
+
+#define CB_30PIN_MAG "TP"
+#define CP_30PIN_MAG_LEN (2)
+
+#define CB_30PIN_BUFFER_LEN (498)
+#define CB_30PIN_EOP_LEN (11)
/// @brief 30pin recovery header.
/// @param mag magic number.
@@ -17,10 +25,21 @@
/// @param eop end of packet data.
struct _cb_tpin_recovery_packet
{
- uint8_t mag[2];
+ uint8_t mag[CP_30PIN_MAG_LEN];
uint8_t kind;
- uint8_t buffer[498];
- uint8_t eop[11];
+ uint8_t buffer[CB_30PIN_BUFFER_LEN];
+ uint8_t eop[CB_30PIN_EOP_LEN];
+};
+
+/// @brief 30pin recovery packet kinds.
+enum
+{
+ TPIN_RECOVERY_PACKET_KIND_UNKNOWN = 0,
+ TPIN_RECOVERY_PACKET_KIND_BOOT = 1,
+ TPIN_RECOVERY_PACKET_KIND_DATA = 2,
+ TPIN_RECOVERY_PACKET_KIND_EOP = 3,
+ TPIN_RECOVERY_PACKET_KIND_EOP_ACK = 4,
+ TPIN_RECOVERY_PACKET_KIND_EOP_NACK = 5,
};
typedef struct _cb_tpin_recovery_packet cb_tpin_recovery_packet_t; \ No newline at end of file
diff --git a/lib/bootnet.h b/lib/bootnet.h
index 3ce6763..81e0981 100644
--- a/lib/bootnet.h
+++ b/lib/bootnet.h
@@ -9,22 +9,24 @@
#include <lib/boot.h>
#define BOOTNET_INET_MAGIC "NETB"
-#define BOOTNET_INET_MAGIC_LEN 4
+#define BOOTNET_INET_MAGIC_LEN (4)
+
+#define BOOTNET_NAME_LEN (256)
/// @brief Netboot Internet Header
/// Consists of 4 magic characters, and a set of fields describing the current patch that's being sent (if m_preflight = 0)
/// @note Can be used to patch ROMs too (if m_implies_rom = 1)
typedef struct bootnet_inet_header
{
- char m_nb1; /// magic char 1 'N'
- char m_nb2; /// magic char 2 'E'
- char m_nb3; /// magic char 3 'T'
- char m_nb4; /// magic char 4 'B'
+ ascii_char_t m_nb1; /// magic char 1 'N'
+ ascii_char_t m_nb2; /// magic char 2 'E'
+ ascii_char_t m_nb3; /// magic char 3 'T'
+ ascii_char_t m_nb4; /// magic char 4 'B'
- char m_patch_name[255]; /// example: ColdChoco
+ ascii_char_t m_patch_name[BOOTNET_NAME_LEN]; /// example: ColdChoco
int32_t m_length; /// The patch's length.
- char m_target[255]; /// The target file.
- uint8_t m_implies_rom; /// does it imply an EEPROM program?
+ ascii_char_t m_target[BOOTNET_NAME_LEN]; /// The target file.
+ uint8_t m_implies_program; /// does it imply reprogramming?
uint8_t m_preflight; /// Do we just check if this endpoint exists/is valid?
uint8_t m_blob[];
} bootnet_inet_header;