@@ -113,16 +113,20 @@ int map_device( const char* uio_name)
113
113
// provide the maps in the wrong order.
114
114
for (map_nr = 0 ; map_nr < MAX_UIO_MAPS ; ++ map_nr ) {
115
115
DIR * dir = opendir ( path );
116
- if (debug && debug_level > 2 ) {
117
- printf ( " opendir( '%s') returned %d, errno = %d\n" , path , (int )dir , errno );
118
- }
119
116
if (dir == NULL ) {
117
+ if (debug && debug_level > 2 ) {
118
+ printf ( " opendir( '%s') failed, errno = %d\n" , path , errno );
119
+ }
120
120
if (errno == ENOENT ) {
121
121
break ; // done
122
122
} else {
123
123
perror ( " Cannot open map directory" );
124
124
exit ( 1 );
125
125
}
126
+ } else {
127
+ if (debug && debug_level > 2 ) {
128
+ printf ( " opendir( '%s') returned %d\n" , path , (int )dir );
129
+ }
126
130
}
127
131
closedir ( dir );
128
132
info = & map_info [ map_nr ];
@@ -263,13 +267,21 @@ int locate_pruss_device( const char* driver_name, char* drv_name, int drv_name_l
263
267
DIR * dir ;
264
268
struct dirent * de ;
265
269
int found = 0 ;
270
+
266
271
// for each driver instance of type 'driver_name', scan all subdirs of
267
272
// /sys/bus/platform/devices/<driver_name>.<instance>/uio/
268
273
snprintf ( buffer , sizeof ( buffer ), "/sys/bus/platform/drivers/%s" , driver_name );
269
274
dir = opendir ( buffer );
270
275
if (dir <= 0 ) {
271
- perror ( "Platform driver not found" );
272
- exit ( 1 );
276
+ printf ( "module '%s' is not loaded, trying to load it...\n" , driver_name );
277
+ system ( "/sbin/modprobe uio_pruss" );
278
+ // FIXME: find proper solution: mmap later on will fail if we don't delay here
279
+ system ( "sleep 1" );
280
+ dir = opendir ( buffer );
281
+ if (dir <= 0 ) {
282
+ perror ( "Platform driver not found" );
283
+ exit ( 1 );
284
+ }
273
285
}
274
286
for (de = readdir ( dir ) ; de ; de = readdir ( dir )) {
275
287
if (de < 0 ) {
0 commit comments