aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvetch <vetch97@gmail.com>2019-10-15 17:33:12 +0200
committervetch <vetch97@gmail.com>2019-10-15 17:33:12 +0200
commit2632ef73aa04a6b08f4b4061effd2d4390c77b83 (patch)
tree2a84e945b79d48ddf113f9aa4936c5c186528bfd
parent29f996e03b36f6cd390d99ff260ab251e19a6e69 (diff)
downloadrpi-MMU-example-2632ef73aa04a6b08f4b4061effd2d4390c77b83.tar.gz
rpi-MMU-example-2632ef73aa04a6b08f4b4061effd2d4390c77b83.zip
test size, write by rs232 lib
-rw-r--r--Makefile3
-rw-r--r--pipe_image.c23
2 files changed, 18 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index adb74d0..b05600f 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@ loader_stage2.elf : loader_stage2.o uart.o
loader_stage2.img : loader_stage2.elf
arm-none-eabi-objcopy $^ -O binary $@
+ test -n "$$(find $@ -size -16384c)" || exit -1
loader_stage2_embeddable.o : loader_stage2.img
arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata $^ $@
@@ -49,7 +50,7 @@ qemu-bin : loader.img kernel7.img pipe_image
qemu-loader : loader.img
qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^
-pipe_image : pipe_image.c
+pipe_image : pipe_image.c RS-232/rs232.c
gcc -Wall -std=gnu99 -O3 $^ -o $@
clean :
diff --git a/pipe_image.c b/pipe_image.c
index 7e24ea7..7856571 100644
--- a/pipe_image.c
+++ b/pipe_image.c
@@ -3,6 +3,7 @@
#include <endian.h>
#include <stdint.h>
#include <sys/types.h>
+#include "RS-232/rs232.h"
#define ANSI_FG_RED "\033[0;31m"
@@ -12,7 +13,7 @@
int main(int argc, char **argv) {
char *image_file_name = argc > 1 ? argv[1] : "kernel7.img";
-
+
FILE *image_file_handle = fopen(image_file_name, "r");
if (!image_file_handle)
@@ -31,15 +32,21 @@ int main(int argc, char **argv) {
if (fseek(image_file_handle, 0, SEEK_SET))
err(-1, "error navigating through file");
+ //init comport
+ int comport=16;
+
+ if(RS232_OpenComport(comport,115200,"8N1",0)==1)
+ err(1,"Error opening comport");
+
+
uint32_t image_size_le = htole32(image_size);
- if (fwrite(&image_size_le, 4, 1, stdout) != 1)
- err(-1, "couldn't write to stdout");
+ if (RS232_SendBuf(comport,(unsigned char*)&image_size_le,4) == 1)
+ err(1, "error writing number to serial");
ssize_t bytes_left = image_size;
-
- char buf[1024];
+ unsigned char buf[1024];
while (bytes_left)
{
size_t bytes_read;
@@ -47,9 +54,11 @@ int main(int argc, char **argv) {
< 1)
err(-1, "error reading the file");
- if (fwrite(buf, bytes_read, 1, stdout) != 1)
- err(-1, "error writing to stdout");
+ if (RS232_SendBuf(comport,buf,bytes_read) == 1)
+ err(1, "error writing to serial");
bytes_left -= bytes_read;
}
+ RS232_CloseComport(comport);
+
}