Changeset 16


Ignore:
Timestamp:
Oct 31, 2008, 11:55:55 AM (15 years ago)
Author:
guillaume
Message:

Publication tt-loader v0.2.2

Location:
tt-loader
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • tt-loader/Makefile

    r15 r16  
    55LDFLAGS = -g $(LIBS)
    66APP_NAME = tt-loader
    7 APP_VERSION = 0.2.1
     7APP_VERSION = 0.2.2
    88
    99# Adapt this to your system
     
    3030pkg: 2nd
    3131        rm -f $(APP_NAME)-$(APP_VERSION).tar.gz
    32         tar czf $(APP_NAME)-$(APP_VERSION).tar.gz Makefile *.c COPYING README \
    33                 CMD-SYNTAX commands.txt write-splash.txt FlashWriteNAND.txt \
    34                 tt-loader.sh 2nd/arm.ld 2nd/*.h 2nd/*.c 2nd/Makefile 2nd/start.S 2nd/2nd.bin
     32        mkdir -p $(APP_NAME)-$(APP_VERSION)/2nd
     33        cp -a Makefile *.c COPYING README CMD-SYNTAX start-kernel.txt \
     34                commands.txt write-splash.txt FlashWriteNAND.txt tt-loader.sh \
     35                $(APP_NAME)-$(APP_VERSION)
     36        cp -a 2nd/arm.ld 2nd/*.h 2nd/*.c 2nd/Makefile 2nd/start.S 2nd/2nd.bin \
     37                $(APP_NAME)-$(APP_VERSION)/2nd
     38        tar czf $(APP_NAME)-$(APP_VERSION).tar.gz $(APP_NAME)-$(APP_VERSION)
     39        rm -rf $(APP_NAME)-$(APP_VERSION)
    3540
    3641%.dis: %.bin
  • tt-loader/commands.txt

    r12 r16  
    453453end
    454454/////////////////////////////////////////////////////////////////// READNAND END
     455
     456/////////////////////////////////////////////////////////////////// KERNEL
     457# Booting TT with modified hosted u-boot
     458a 0x20010000
     459f x-load.bin
     460
     461// Call a sub from x-load.bin: TT BoardInit (should only work with TT)
     462a 0x20010da4
     463c
     464
     465// Load updated u-boot.bin
     466a 0x10280000
     467f u-boot-updated.bin
     468
     469a 0x11800000
     470f uImage.bin
     471
     472// Send u-boot start address and boot there, u-boot "bootcmd" must has
     473// fixed to not download kernel from NAND but always boot the kernel
     474// loaded at 0x11800000 address in RAM
     475a 0x10280000
     476b
     477
     478end
     479/////////////////////////////////////////////////////////////////// KERNEL END
    455480
    456481/////////////////////////////////////////////////////////////////// U-BOOT
  • tt-loader/main.c

    r13 r16  
    6666static double ticks ;
    6767
    68 #define log1(X)         fprintf(stderr, "%9.3f: "X,((double)times(NULL)-btime)/ticks)
    6968#define log2(X,Y)       fprintf(stderr, "%9.3f: "X,((double)times(NULL)-btime)/ticks,(Y))
    7069#define log3(X,Y,Z)     fprintf(stderr, "%9.3f: "X,((double)times(NULL)-btime)/ticks,(Y),(Z))
     
    7877# define le32_to_cpu(x) bswap_32 (x)
    7978#endif
     79
     80static inline double chrono ()
     81{
     82        return ((double)times(NULL)-btime)/ticks ;
     83}
     84
     85static inline void log1 ( const char *msg )
     86{
     87        fprintf(stderr, "%9.3f: ", chrono());
     88        return (void)fprintf(stderr, msg);
     89}
    8090
    8191static inline unsigned round_up (unsigned v, unsigned d)
     
    248258        for (;;)
    249259        {
    250                 err= usb_set_configuration (handle, 1);
     260                err= -usb_set_configuration (handle, 1);
    251261                if (err == 0)
    252262                        break;
    253                
    254                 if (err == -ENODEV)
     263
     264// TODO: l'erreur ENODEV est peut-être juste un problème temporaire dans le noyau
     265// et peut réclamer de ré-essayer, y compris plus tard dans le code
     266                if (err == ENODEV)
    255267                {
    256                         log1("OMAP error, retrying\n");
     268                        log1("OMAP error, aborting\n");
    257269                        return 1;
    258270                }
     271                else if (err == EPERM)
     272                {
     273                        log1("USB error, you don't have rights to open OMAP device, aborting\n");
     274                        return 1;
     275                }
     276                else if (err == ETIME)
     277                {
     278                        log1("OMAP error, you need to reboot your OMAP device, aborting\n");
     279                        return 1;
     280                }
     281                else
     282                        log2("OMAP error %d, retrying\n",err);
    259283               
    260                 sleep (1);
     284                usleep (100000);
    261285        }
    262286       
     
    814838                                                                        log1("Asking boot\n");
    815839                                                                        // Quit now witout error set
    816                                                                         loop = err = -10 ;
     840                                                                        loop = err = 0 ;
    817841                                                                        cmd = cmdfile.size ;
    818842                                                                        res = 1 ;
     
    839863                                                                {
    840864                                                                        log2("Can't read mach id '%s'\n",&cmdp[cmd]);
    841                                                                         loop = 0 ; // Just quit on error
     865                                                                        loop = -10 ; // Just quit on error
    842866                                                                        break ;
    843867                                                                }
     
    845869                                                                        log1("Asking kernel to boot\n");
    846870                                                                        // Quit now witout error set
    847                                                                         loop = err = -10 ;
     871                                                                        loop = err = 0 ;
    848872                                                                        cmd = cmdfile.size ;
    849873                                                                        res = 1 ;
     
    919943int main (int argc, char *argv[])
    920944{
    921         int     size;
     945        int     size, err=-1;
    922946        btime = (double) times(NULL);
    923947        ticks = (double) sysconf(_SC_CLK_TCK) / 1000 ;
     
    925949        if (argc < NUM_ARGS)
    926950        {
    927                 log2("Usage: %s <2nd_boot_file> <command_file>\n", argv[ARG_PROGNAME]);
     951                fprintf(stderr, "Usage: %s <2nd_boot_file> <command_file>\n", argv[ARG_PROGNAME]);
    928952                return 1;
    929953        }
     
    931955        memset (buffer, 0, 128);
    932956       
    933         u_int32_t       *p= (u_int32_t *) buffer;
     957        u_int32_t *p= (u_int32_t *) buffer;
    934958        p[0x00]= cpu_to_le32 (0xf0030002);
    935959       
     
    10031027        {
    10041028                log1("Searching OMAP730-USB connection...\n");
    1005                 struct usb_bus  *bus;
    1006                 for (bus= usb_get_busses (); bus; bus= bus->next)
     1029                while ( chrono() < 30000 )
    10071030                {
    1008                         struct usb_device       *dev;
     1031                        struct usb_bus  *bus;
     1032                        for (bus= usb_get_busses (); bus; bus= bus->next)
     1033                        {
     1034                                struct usb_device       *dev;
     1035                                                       
     1036                                for (dev= bus->devices; dev; dev= dev->next)
     1037                                {
     1038                                        usb_dev_handle  *handle;
     1039                                        if (dev->descriptor.idVendor == OMAP_VENDOR  &&
     1040                                                dev->descriptor.idProduct == OMAP_PRODUCT  &&
     1041                                                (handle= usb_open (dev)) != NULL)
     1042                                        {
     1043                                                log1("Found OMAP730-USB connection\n");
     1044                                                int res= process (handle);
     1045// TODO Ajouter la déconnexion de la device avec une option pour la garder (cas de renvoi de console)
     1046                                                usb_close (handle);
     1047                                                if (res == 0) {
     1048                                                        log1("OMAP730-USB connection processed\n");
     1049                                                        err = 0 ;
     1050                                                        break ;
     1051                                                       
     1052                                                } else {
     1053                                                        log1("OMAP730-USB processing failed\n");
     1054                                                        err = 1 ;
     1055                                                        break ;
     1056                                                }
     1057                                        }
     1058                                }
     1059                                if ( err >= 0 )
     1060                                        break ;
     1061                        }
    10091062                       
    1010                         for (dev= bus->devices; dev; dev= dev->next)
    1011                         {
    1012                                 usb_dev_handle  *handle;
    1013                                 if (dev->descriptor.idVendor == OMAP_VENDOR  &&
    1014                                         dev->descriptor.idProduct == OMAP_PRODUCT  &&
    1015                                         (handle= usb_open (dev)) != NULL)
    1016                                 {
    1017                                         log1("Found OMAP730-USB connection\n");
    1018                                         int res= process (handle);
    1019                                         usb_close (handle);
    1020                                         if (res == 0) {
    1021                                                 log1("OMAP730-USB connection processed\n");
    1022                                                 return 0 ;
    1023                                         } else
    1024                                                 log1("OMAP730-USB processing failed\n");
    1025                                 }
    1026                         }
     1063                        if ( err >= 0 )
     1064                                break ;
     1065                       
     1066                        while ( ! usb_find_devices() && chrono() < 5000 )
     1067                                usleep(10000);
    10271068                }
     1069               
     1070                if (err<0)
     1071                        log1("Time-out: No OMAP-730 found\n");
     1072       
    10281073               
    10291074        } else {
     
    10341079        if (cmdfile.content!=NULL)
    10351080                free((void *)cmdfile.content);
    1036        
    1037         log1("No target connection found\n");
     1081
    10381082        return 1 ;
    10391083}
Note: See TracChangeset for help on using the changeset viewer.