• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/package/mkpimage/mkpimage.c
Jan ViktorinJan Viktorin committed ea9797c846e20 Oct 2015
Raw file
Source viewDiff to previous
        fprintf(stderr, "input image too big. Maximum is %d bytes, got %ld bytes\n",
 
1
#include <stdio.h>
2
#include <unistd.h>
3
#include <getopt.h>
4
#include <stdlib.h>
5
#include <stdint.h>
6
#include <string.h>
7
#include <errno.h>
8
#include <sys/types.h>
9
#include <sys/stat.h>
10
#include <fcntl.h>
11
#include <endian.h>
12
​
13
#define VALIDATION_WORD 0x31305341
14
​
15
#define MAX_IMAGE_SIZE (60 * 1024 - 4)
16
​
17
static int add_barebox_header;
18
​
19
struct socfpga_header {
20
    uint8_t validation_word[4];
21
    uint8_t version;
22
    uint8_t flags;
23
    uint8_t program_length[2];
24
    uint8_t spare[2];
25
    uint8_t checksum[2];
26
};
27
​
28
static uint32_t bb_header[] = {
29
    0xea00007e, /* b 0x200  */
30
    0xeafffffe, /* 1: b 1b  */
31
    0xeafffffe, /* 1: b 1b  */
32
    0xeafffffe, /* 1: b 1b  */
33
    0xeafffffe, /* 1: b 1b  */
34
    0xeafffffe, /* 1: b 1b  */
35
    0xeafffffe, /* 1: b 1b  */
36
    0xeafffffe, /* 1: b 1b  */
37
    0x65726162, /* 'bare'   */
38
    0x00786f62, /* 'box\0'  */
39
    0x00000000, /* padding  */
40
    0x00000000, /* padding  */
41
    0x00000000, /* padding  */
42
    0x00000000, /* padding  */
43
    0x00000000, /* padding  */
44
    0x00000000, /* padding  */
45
    0x00000000, /* socfpga header */
46
    0x00000000, /* socfpga header */
47
    0x00000000, /* socfpga header */
48
    0xea00006b, /* entry. b 0x200  */
49
};
50
​
51
static int read_full(int fd, void *buf, size_t size)
52
{
53
    size_t insize = size;
54
    int now;
55
    int total = 0;
56
​
57
    while (size) {
58
        now = read(fd, buf, size);
59
        if (now == 0)
60
            return total;
61
        if (now < 0)
62
            return now;
63
        total += now;
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.