new test using malloc()
This commit is contained in:
		
							parent
							
								
									d575410a06
								
							
						
					
					
						commit
						2e9044a68c
					
				|  | @ -1,15 +1,15 @@ | ||||||
| TARGET   = test_malloc | TARGET   = malloc_test | ||||||
| 
 | 
 | ||||||
| TARGET_ARCH=riscv32 | TARGET_ARCH = riscv32 | ||||||
| 
 | 
 | ||||||
| CC       = riscv32-unknown-elf-gcc | CC       = riscv32-unknown-elf-gcc | ||||||
| 
 | 
 | ||||||
| # compiling flags here
 | # compiling flags here
 | ||||||
| CFLAGS = -Wall -I. -O0 -static --specs=nosys.specs | CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nosys.specs | ||||||
| 
 | 
 | ||||||
| LINKER   = riscv32-unknown-linux-gnu-gcc | LINKER   = riscv32-unknown-elf-gcc | ||||||
| # linking flags here
 | # linking flags here
 | ||||||
| LDFLAGS   = -I. --entry main -L/opt/riscv/riscv32-unknown-elf/lib/ -T ld_script.ld | LDFLAGS   = -I. -static  | ||||||
| LIBS   = $(EXTRA_LIBS) | LIBS   = $(EXTRA_LIBS) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -24,19 +24,19 @@ LIBDIR = -L. | ||||||
| SOURCES  := $(wildcard $(SRCDIR)/*.c) | SOURCES  := $(wildcard $(SRCDIR)/*.c) | ||||||
| INCLUDES := $(wildcard $(INCDIR)/*.h) | INCLUDES := $(wildcard $(INCDIR)/*.h) | ||||||
| OBJECTS  := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o) | OBJECTS  := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o) | ||||||
|  | 
 | ||||||
| rm       = rm -f | rm       = rm -f | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| $(BINDIR)/$(TARGET): $(OBJECTS) | $(BINDIR)/$(TARGET): $(OBJECTS) | ||||||
| #	$(LINKER) $(OBJECTS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o $@
 | 	$(LINKER) $(CFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) $(OBJECTS) -o $@ | ||||||
| 	riscv32-unknown-elf-objdump -d $< > dump | 	riscv32-unknown-elf-objdump -d $@ > dump | ||||||
| 	objcopy -Oihex $< $(TARGET).hex | 	riscv32-unknown-elf-objcopy -Oihex $@ $(TARGET).hex | ||||||
| #	@echo "Linking complete!"
 | 	@echo "Linking complete!" | ||||||
| 
 | 
 | ||||||
| $(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c | $(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c | ||||||
| 	@echo "Compiling "$<" ..." | 	@echo "Compiling "$<" ..." | ||||||
| #	$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
 | 	$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@ | ||||||
| 	$(CC) $(CFLAGS) $(INCDIR) $< -o $@ |  | ||||||
| 	@echo "Done!" | 	@echo "Done!" | ||||||
| 
 | 
 | ||||||
| .PHONY: clean | .PHONY: clean | ||||||
|  | @ -46,5 +46,5 @@ clean: | ||||||
| 
 | 
 | ||||||
| .PHONY: remove | .PHONY: remove | ||||||
| remove: clean | remove: clean | ||||||
| 	@$(rm) $(BINDIR)/$(TARGET) | 	@$(rm) $(BINDIR)/$(TARGET) $(OBJECTS) | ||||||
| 	@echo "Executable removed!" | 	@echo "Executable removed!" | ||||||
|  | @ -0,0 +1,35 @@ | ||||||
|  | #include <string.h> | ||||||
|  | #include <stdio.h> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | #define TRACE (*(unsigned char *)0x40000000) | ||||||
|  | int _read(int file, char* ptr, int len) { | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int _close(int fd){ | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int _fstat_r(int fd) { | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int _lseek_r(struct _reent *ptr, FILE *fp, long offset, int whence){ | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int _isatty_r(struct _reent *ptr, int fd) { | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int _write(int file, const char *ptr, int len) { | ||||||
|  |   int x; | ||||||
|  | 
 | ||||||
|  |   for (x = 0; x < len; x++) { | ||||||
|  |     TRACE =  *ptr++; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   return (len); | ||||||
|  | } | ||||||
|  | 
 | ||||||
										
											Binary file not shown.
										
									
								
							|  | @ -2,45 +2,9 @@ | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| #include <errno.h> |  | ||||||
| #include <sys/stat.h> |  | ||||||
| 
 | 
 | ||||||
| #define BUFFER_SIZE (512) | #define BUFFER_SIZE (512) | ||||||
| #define TRACE (*(unsigned char *)0x40000000) |  | ||||||
| 
 | 
 | ||||||
| extern int  errno; |  | ||||||
| 
 |  | ||||||
| int _write(int file, const char *ptr, int len) { |  | ||||||
|   int x; |  | ||||||
| 
 |  | ||||||
|   for (x = 0; x < len; x++) { |  | ||||||
|     TRACE =  *ptr++; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   return (len); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int _read (int   file, char *ptr, int   len) { |  | ||||||
|   return  0; |  | ||||||
| }   |  | ||||||
| 
 |  | ||||||
| int _close (int   file) { |  | ||||||
|   errno = EBADF; |  | ||||||
|   return -1; |  | ||||||
| }  |  | ||||||
| 
 |  | ||||||
| int _fstat (int file, struct stat *st) { |  | ||||||
|   st->st_mode = S_IFCHR; |  | ||||||
|   return  0; |  | ||||||
| }    |  | ||||||
| 
 |  | ||||||
| int _isatty (int   file) { |  | ||||||
|   return  1; |  | ||||||
| }  |  | ||||||
| 
 |  | ||||||
| int _lseek (int file, int offset, int whence) { |  | ||||||
|   return  0; |  | ||||||
| }  |  | ||||||
| 
 | 
 | ||||||
| int main(void) { | int main(void) { | ||||||
|   uint16_t *buffA, *buffB;   |   uint16_t *buffA, *buffB;   | ||||||
		Loading…
	
		Reference in New Issue